views:

234

answers:

2

hi all, i have two clients in two different processes that communicate through RMI with the server.

my question is: what happends if both clients invoking the server's stub at the same time?

thanks for you time, me

A: 

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.

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.

banjollity
+2  A: 

This tutorial demonstrates the threaded nature of RMI servers (see task 7.1). They quote from the RMI spec:

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

so invocations from different clients will result in execution via different threads in the server.

Brian Agnew
thanks Brian, i have another question regarding your answer: since invocation from 2 different clients will be executed in a different threadis that guaranteed that the if my RMI object is stateless the wrapping RMI object is stateless as well?thanks again
BTW like the company name... OOPS consultancy