Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sync.wait();

 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic