【发布时间】:2014-07-16 08:33:08
【问题描述】:
我无法理解 java RMI 的特定方面。
有一个客户端创建了 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));
}
“gestoresportelli”之前在服务器中注册为服务。
因此,就我的理解而言,客户端都被赋予了对 SAME 对象的所有相同引用。
我这里要问的是,当我在这个对象上调用一个方法时,是不是客户端在执行服务器的代码?
还是服务器按顺序调用该对象上的方法?
所以假设我们有:
线程1,线程2,线程3。它们都在服务器上注册的同一个远程对象上调用相同的方法。
他们是否按顺序调用它:
Thread1->RemoteObjectReference.doSomething();
wait thread 1 to finish...
Thread2->RemoteObjectReference.doSomething();
wait thread 2 to finish...
Thread3->RemoteObjectReference.doSomething();
或同时:
Thread1->RemoteObjectReference.doSomething();
Thread2->RemoteObjectReference.doSomething();
Thread3->RemoteObjectReference.doSomething();
所有同时,即使那是同一个远程对象?
我希望我已经足够清楚了。谢谢!
【问题讨论】:
-
我发现我的问题和这个类似:stackoverflow.com/questions/1300145/…
标签: java multithreading client-server rmi client-side