简体   繁体   English

取消导出作为远程方法调用中的参数传递的远程对象

[英]Unexporting remote objects passed as arguments in remote method call

I was wondering if there's a need to explicitly unexport a remote object passed as a parameter in a remote method call when they don't need to exist anymore. 我想知道是否有必要在不再需要远程对象调用时显式取消导出作为远程方法调用中的参数传递的远程对象。 For example: I've an online game, when the client asks the GameServer(binded in a RMI registry) for a game the server returns to the client a GameHandler as a remote object. 例如:我有一个在线游戏,当客户端向GameServer(绑定在RMI注册表中)询问游戏时,服务器将作为远程对象的GameHandler返回给客户端。 When the game is over and the GameHandler has no need to be active anymore, do I have to call UnicastRemoteObject.unexportObject(this, false); 当游戏结束并且GameHandler不再需要活动时,我是否必须调用UnicastRemoteObject.unexportObject(this, false); ? I'm doing it but sometimes I get a NoSuchObjectException . 我正在执行此操作,但有时会收到NoSuchObjectException

It will be unexported automatically via DGC and local GC when there are no remote or local references. 如果没有远程或本地引用,它将通过DGC和本地GC自动取消导出。 If you want to know when DGC has kicked in, implement the Unreferenced interface. 如果您想知道何时启动DGC,请实现Unreferenced接口。

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

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