LocateRegistry.createRegistry(1099);
creates a new daemon thread named RMI TCP Accept-1099 on my machine. This topic essentially listens to new TCP / IP connections on 1099.
Daemon threads are automatically destroyed when exiting the JVM. And in your case, the JVM exits when you leave the main() method. More precisely - it exits when there are no non-demon threads - and, apparently, in your application there is only one thread without a daemon (named main ).
So, you have two options:
- Do not let the
main() method complete by adding infinite sleep() . - create a non-daemon stream. Of course, do this only when the thread is really doing something useful, rather than preventing the JVM from exiting.
source share