简体   繁体   English

并发访问远程对象Java RMI

[英]Concurrent access to a Remote Object Java RMI

I am currently studying how Java RMI works but I do not understand a certain aspect. 我目前正在研究Java RMI的工作原理,但是我不了解某些方面。
In a non-distributed multithredaded environment if methods on the same object are called simultaneously from different threads each of them will be executed on the respective thread's stack (accessing shared data is not a part of my question). 在非分布式多用途环境中,如果从不同线程中同时调用同一对象上的方法,则每个方法都将在相应线程的堆栈上执行(访问共享数据不是我的问题的一部分)。
In a distributed system since a client process calls methods on the stub and the actual call is executed on the stack of the process that created the remote object how are simultaneous calls to a method handled? 在分布式系统中,由于客户端进程在存根上调用方法,而实际调用是在创建远程对象的进程的堆栈上执行的,如何同时调用方法? In other words what happens at the lets say server thread when there are two (or more) requests to execute the same method on that thread? 换句话说,当有两个(或更多)请求在该线程上执行相同方法时,在说服务器线程上发生了什么?
I thought of this question as I want to compare this to what I am used to - the executions being on different stacks. 我想到这个问题是因为我想将其与我所习惯的进行比较-执行在不同的堆栈上。

how are simultaneous calls to a method handled? 如何同时调用方法?

It isn't specified. 未指定。 It is carefully stated in the RMI specification : "The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads." RMI规范中对此进行了详细说明:“ RMI运行时不保证将远程对象调用映射到线程。”

The occult meaning of this is that you can't assume the server is single-threaded. 隐秘的含义是您不能假定服务器是单线程的。

In other words what happens at the lets say server thread when there are two (or more) requests to execute the same method on that thread? 换句话说,当有两个(或更多)请求在该线程上执行相同方法时,在说服务器线程上发生了什么?

There can't be two or more requests to execute the method on the same thread. 在同一线程上不能有两个或多个执行该方法的请求。 The question doesn't make sense. 这个问题没有道理。 You've posited a unique 'lets say server thread' that doesn't actually exist. 您已经放置了一个实际上不存在的唯一“让服务器说线程”。

There can however be two or more requests to execute the method arising from two or more concurrent clients, or two or more concurrent threads in a single client, or both, and because of the wording of the RMI Specification you can't assume a single-threaded despatching model at the server. 但是,可能有两个或多个请求执行该方法,这是由两个或多个并发客户端或一个客户端中有两个或多个并发线程引起的,或者两者都存在,并且由于RMI规范的用语,您不能假设一个服务器上的线程调度模型。

In the Oracle/Sun implementation it is indeed multi-threaded, ditto the IBM implementation. 在Oracle / Sun实现中,它确实是多线程的,与IBM实现相同。 I'm not aware of any RMI implementation that isn't multi-threaded, and any such implementation would be basically useless. 我不知道任何不是多线程的RMI实现,任何这样的实现基本上都是无用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM