[英]Java RMI threads on client-side are executing sequentially or concurrently when calling the same remote object?
I am having trouble understanding a specific aspect of java RMI. 我在理解Java RMI的特定方面时遇到麻烦。
There's a client that creates N threads that do a lookup on the RMIregistry: 有一个客户端创建了N个线程,这些线程在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. 先前在服务器中将“ gestoresportelli”注册为服务的位置。
So, as far as my understanding goes, the clients are given all the same reference to the SAME object. 因此,据我所知,客户端对SAME对象的引用都相同。
What I am asking here is, when I call a method on this object, is it the CLIENT executing the server's code? 我要问的是,当我在此对象上调用方法时,是CLIENT执行服务器代码吗?
Or is it the server that sequentially calls methods on that object? 还是服务器依次调用该对象上的方法?
So supposing we have: 因此,假设我们有:
thread1, thread2, thread3. 线程1,线程2,线程3。 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!
谢谢!
What I am asking here is, when I call a method on this object, is it the CLIENT executing the server's code?
我要问的是,当我在此对象上调用方法时,是CLIENT执行服务器代码吗?
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. 更明确地说,RMI规范特别声明不保证有关客户端线程和服务器线程之间的关联。
All you can deduce from that is that you cannot assume it is single-threaded. 您可以从中得出的所有结论是,您不能假定它是单线程的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.