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 Web Component Certification (SCWCD/OCPJWCD) and the fly likes wait and notify in Threads 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 » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "wait and notify in Threads" Watch "wait and notify in Threads" New topic
Author

wait and notify in Threads

K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 66
Can Any body help in finding the answer for this question.

Which statement is true?
A. If only one thread is blocked in the wait method of an object, and another thread
executes the modify on that same object, then the first thread immediately
resumes execution.
B. If a thread is blocked in the wait method of an object, and another thread
executes the notify method on the same object, it is still possible that the first
thread might never resume execution.
C. If a thread is blocked in the wait method of an object, and another thread
executes the notify method on the same object, then the first thread definitely
resumes execution as a direct and sole consequence of the notify call.
D. If two threads are blocked in the wait method of one object, and another thread
executes the notify method on the same object, then the first thread that executed
the wait call first definitely resumes execution as a direct and sole consequence
of the notify call.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
option "B" is the correct answer.

Regarding option "C"


then the first thread definitely resumes execution as a direct and sole consequence of the notify call.


Very little is guaranteed in threads. Once a thread is blocked-for-lock-acquisition and when another thread calls notify this threads goesto ready-to-run state and NOT running state directly.

NOTE: This is NOT the correct forum for this(Thread) question.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Anurag Jain
Greenhorn

Joined: Jul 23, 2002
Posts: 8
I would agree and i have deleted my earlier post in favor of this correct answer!


--<br />Anurag
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: wait and notify in Threads
 
Similar Threads
Thread Q
Threads Threads and Threads
Threads
some intersting questions
thread