Reputation: 1174
I am having trouble understanding a specific aspect of java RMI.
There's a client that creates N threads that do a lookup on the RMIregistry:
Registry rmiRegistry;
try {
rmiRegistry = LocateRegistry.getRegistry(8585);
IGestoreSportello igs = (IGestoreSportello)rmiRegistry.lookup("gestoresportelli");
ExecutorService s = Executors.newCachedThreadPool();
for(int i = 0; i < T; i++){
s.execute(new threadRunner(igs));
}
Where "gestoresportelli" was previously registered as a service in the Server.
So, as far as my understanding goes, the clients are given all the same reference to the SAME object.
What I am asking here is, when I call a method on this object, is it the CLIENT executing the server's code?
Or is it the server that sequentially calls methods on that object?
So supposing we have:
thread1, thread2, thread3. They all call the same method on the same remote object which was registered on the server.
Do they call it sequentially:
Thread1->RemoteObjectReference.doSomething();
wait thread 1 to finish...
Thread2->RemoteObjectReference.doSomething();
wait thread 2 to finish...
Thread3->RemoteObjectReference.doSomething();
OR concurrently:
Thread1->RemoteObjectReference.doSomething();
Thread2->RemoteObjectReference.doSomething();
Thread3->RemoteObjectReference.doSomething();
all at the same time, even tho that's the same remote object?
I hope I was clear enough. Thanks!
Upvotes: 0
Views: 1057
Reputation: 310980
What I am asking here is, when I call a method on this object, is it the CLIENT executing the server's code?
No.
Or is it the server that sequentially calls methods on that object?
It is the server, but sequentiality isn't defined.
Do they call it sequentially
It isn't defined.
OR concurrently:
It isn't defined.
To put that more strongly, the RMI specification states specifically that there are no guarantees about associations between client threads and server threads.
All you can deduce from that is that you cannot assume it is single-threaded.
Upvotes: 1