开发者

In Java, how can a server change its RMI client's thread id?

I have a remote object that serves a number of clients via Java RMI and thus I need the remote obj开发者_开发知识库ect to be able to identify its clients. I'm thinking of assigning unique ids to client by having the remote object calling Thread.currentThread().setId(). I'm assuming that the server will see each client as a separate thread.

Could you please show me how I can test this approach with only one machine, which will play both the server and client parts?

And if you think it will not work, how can I solve this problem?

Thank you.


I'm assuming that the server will see each client as a separate thread.

You can't assume that. The RMI specification states that there are no guarantees about the association if any between server threads and client threads.

What you are looking for is RemoteServer.getClientHost().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜