简体   繁体   English

RMI java中的竞争条件 - 2客户端1服务器

[英]race condition in RMI java - 2 client 1 server

i have two clients in two different processes that communicate through RMI with the server. 我有两个不同进程的客户端通过RMI与服务器进行通信。

my question is: what happends if both clients invoking the server's stub at the same time? 我的问题是:如果两个客户端同时调用服务器的存根,会发生什么?

thanks for you time, me 谢谢你的时间,我

This tutorial demonstrates the threaded nature of RMI servers (see task 7.1). 本教程演示了RMI服务器的线程特性(请参阅任务7.1)。 They quote from the RMI spec: 他们引用了RMI规范:

A method dispatched by the RMI runtime to a remote object implementation (a server) may or may not execute in a separate thread. 由RMI运行时调度到远程对象实现(服务器)的方法可以在单独的线程中执行,也可以不在另一个线程中执行。 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 在同一客户端计算机上,无法保证每个方法都在单独的线程中运行

so invocations from different clients will result in execution via different threads in the server. 所以来自不同客户端的调用将导致通过服务器中的不同线程执行。

Nothing untoward by default - it's exactly the same as invoking a method on any other object from two threads simultaneously. 默认情况下没有任何不妥之处 - 它与同时从两个线程调用任何其他对象上的方法完全相同。 The 1 server to many clients model is what network protocols like RMI are for. 1服务器到多客户端模型是像RMI这样的网络协议。

Access to any shared data within the server needs to be regulated by synchronized blocks if need be. 如果需要,可以通过同步块来访问服务器内的任何共享数据。 It depends what the server is doing. 这取决于服务器正在做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM