How to close well when using the in-process Java RMI registry
case
I use the in - process * Java RMI registry in the server process
I bind an object in the registry
My client process connects and finds bindings and passes remote objects
Now I want the server process to shut down cleanly, that is, there are no more Deamon threads Using RMI, I call "close" on an object in the server process. The problem is what the "close" method actually has to do
topic
How do I ensure that non daemon threads are not running in processes that export objects using RMI?
As far as I know, I have to cancel exporting * * all exported objects closed by the JVM? Since many objects have been passed through RMI, I will have to maintain the collection of these objects and the expansion of each object * *
I've read that any exported object should automatically cancel it when the garbage collector (the reference can't be found now), but my experience tells me that some objects (especially distributed?) It may take a long time to be garbage collected, so this is not an option
*Create * * unexport with LocateRegistry and execute with unicastremoteobject
Solution
Cancel everything, including the registry Note that this requires saving the return value of createregistry()
Correct, unless you use an unreferenced facility
You can control all DGC timeouts It is indeed an option through the unreferenced interface