我在两个不同的进程中有两个客户端,它们通过 RMI 与服务器进行通信。
我的问题是: 如果两个客户端同时调用服务器的 stub 会发生什么?
谢谢你的时间, 我
最佳答案
This tutorial演示 RMI 服务器的线程特性(参见任务 7.1)。他们引用了 RMI 规范:
A method dispatched by the RMI runtime to a remote object implementation (a server) may or may not execute in a separate thread. Calls originating from different clients Virtual Machines will execute in different threads. From the same client machine it is not guaranteed that each method will run in a separate thread
因此来自不同客户端的调用将导致通过服务器中的不同线程执行。
关于java - RMI java中的竞争条件 - 2个客户端1个服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1300145/