How to easily close an application using the built-in Java RMI registry

Case

I am using the built-in Java RMI registry in my server process.

I am linking 1 object in the registry.

My client process connects and views binding objects and remote objects.

Now I want the server process to be closed cleanly, i.e. there should no longer be deamon. Using RMI, I call the “close” object in my server process, and the question is what this “private” method should do.

Question

How can I make sure that a process using exported RMI objects does not execute non-daemon threads?

As far as I can read, should I exclude ** all exported objects for the JVM to close? Since many objects were transferred through RMI, I would have to maintain this set of these objects and exclude ** each of them.

I read that any exported object itself must not be exported when the garbage collector (now cannot find the link), but my experience tells me that some objects (especially common ones?) Can take a lot of time so this is not an option.

* Created using LocateRegistry
** Unexport runs with UnicastRemoteObject

+4
source share
1 answer

, RMI -?

, . , createRegistry().

, ** JVM ? RMI, ** .

, Unreferenced.

, ( ), , ( ?) .

- DGC. , Unreferenced.

0

Source: https://habr.com/ru/post/1629706/


All Articles