jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

Question How can I programmatically stop a RMI server?
Derived from A question posed by mike niemaz
Topics Java:API:RMI
Author Edward Harned
Created Nov 8, 2000 Modified Nov 18, 2000


Answer

RMI Servers start a thread that never ends. This is so that the Server is persistent until manually shut down.

However, you can provide a remote method, shutDown(), for the Remote Server.

This method starts a shutdown thread. The shutdown thread remains waiting for a notify().

When the Server finishes all clean-up processing it wakes up the shutdown thread.

The shutdown thread, after a two (2) second delay, calls System.exit(0) to end the Java Virtual Machine. The delay is so that messages from the Server to the initiating Client complete the journey.



Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Comments and alternative answers

Comment on this FAQ entry

RE: How can I programmatically stop a RMI server?
James Haiar, Jun 20, 2001
You can also use the 'unexportObject' method in UnicastRemoteObject. This will allow the server to not accept any more remote calls.

Is this item helpful?  yes  no     Previous votes   Yes: 2  No: 0



Reply to this answer/comment  Help  
Why such a complicated solution?
Strelok Strelok, Apr 23, 2005
I don't understand why you don't just have the shutdown() remote method call the cleanup code and then System.exit(). Why does it need to start another thread and use wait/notify?

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  


Ask A Question



 
Related Links

RMI FAQ

RMI Forum

Sun's RMI-USERS mailing list archive

Sun's RMI home page

Wish List
Features
About jGuru
Contact Us

 



The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers