线程和 RMI 对象

Threads and RMI Objects

在Java RMI 中,是否为每个创建的新远程对象启动一个新线程?

如果是这样,这个线程是不是一种监听线程,它通过为每个方法调用创建一个新线程来服务传入的调用?

我刚刚想出了这个心智模型,我正在寻找验证。

RMI 规范既不规定也不否认任何线程模型。在对程序的远程部分(在服务器中运行的部分)进行编程时,您应该假设两个或多个线程可以同时访问同一个对象,因此您需要同步对可变字段的访问(即使我认为大多数实现序列化调用)

引自the spec

A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute concurrently, a remote object implementation needs to make sure its implementation is thread-safe.