aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt on Thread- wait() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt on Thread- wait()" Watch "Doubt on Thread- wait()" New topic
Author

Doubt on Thread- wait()

Saumya Srivastava
Ranch Hand

Joined: Mar 19, 2007
Posts: 45
Hi,

I was running the code below and thought of commenting the line calling notify(). So that I may see if I get IIlegalMonitorStateException. But the code ran successfully without throwing error. Please explain me why? Isn't it necessary for the thread to send notify() to the waiting thread? I think main() thread should throw the exception after not receiving notification from ThreadB b? Please correct me ...if my understanding is wrong..?



OCPJP 6.0
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

it's not necessary to call notify

It's simply to notify waiting thread to wake up.
if not implemeted,the waiting thread would not wake up
that's it..


OCPJP 6.0 93%
OCPJWCD 5.0 98%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on Thread- wait()