This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread issue" Watch "Thread issue" New topic
Author

Thread issue

Aurelian Dobre
Greenhorn

Joined: Mar 10, 2013
Posts: 1
Hi,

Why the following code doesn't block in the wait() method forever?

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18498
    
  40

Aurelian Dobre wrote:Hi,

Why the following code doesn't block in the wait() method forever?




This issue seems to come up often -- and the quick answer is... The implementation of one of the components of the threading system (in this case, to support the join() method call), uses the wait/notify mechanism. And for some reason, the designer chose to use the thread object as the notification object. This is purely an implementation detail, and hence, may change in the future.

Regardless, don't perform wait() on the thread object, some part of the threading library is already doing that.

Henry



Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread issue
 
Similar Threads
another question from nikos
Misunderstanding with the wait() method.
join method
Thread question
Problem in Threading - 2