This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes sync.wait(); Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "sync.wait();" Watch "sync.wait();" New topic
Author

sync.wait();

Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
In most RMI server code examples there are these lines of codes at the end of the server constructor. What is the purpose of them.
Even without them a server works perfectly.

// wait for invocations from clients
Object sync = new Object();
synchronized (sync) {
sync.wait();
}

Kind regards
Charles.


Charles.<br />(SCJD2)
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The only thing I can think of is that it's there to keep a non-daemon thread alive. If the main() thread would simply exit, the entire JVM would exit because the threads used internally by RMI are all daemon threads.
- Peter
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sync.wait();
 
Similar Threads
Question regarding Synchronized(anObject)
re: CORBA Object Factory & Object Adapters
Problem with wait() / notify()
help me
Getting java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object