简体   繁体   English

具有多个客户端的Java rmi服务器-一次仅接受一个客户端调用

[英]Java rmi server with multiple client - Only accept one client call at the time

I'm developing a standard java RMI server with multiple clients. 我正在开发具有多个客户端的标准Java RMI服务器。 These clients have a menu where they can call the server to do various of things for them. 这些客户端有一个菜单,他们可以在其中调用服务器来为他们执行各种操作。

One method involves a queue, where they can send a job to the queue and wait for it to get handled. 一种方法涉及队列,他们可以在其中将作业发送到队列并等待它得到处理。 The RMI server dispose threads for all the clients automatic, but when it comes to this method and queue, how can I hold this request back, so for example: RMI服务器自动为所有客户端分配线程,但是当涉及到此方法和队列时,如何才能保留此请求,例如:

client 1 call first, and then client 2 calls just after (here client 1 should receive the message first from the server and client 2 should wait the time it takes for the server to process client 1 request) 客户端1首先呼叫,然后客户端2随后呼叫(此处客户端1应该首先从服务器接收消息,而客户端2应该等待服务器处理客户端1请求所花费的时间)

Is it to make some kind of singleton only for this task? 是否仅为此任务设置某种单例? What can I do to tackle this problem. 我该怎么办才能解决这个问题。

Make the remote method concerned synchronized . 使相关的远程方法synchronized

No queue required. 无需队列。

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

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