Forums Register Login

wait and notify in Threads

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
I would agree and i have deleted my earlier post in favor of this correct answer!
No, tomorrow we rule the world! With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 676 times.
Similar Threads
Threads
Threads Threads and Threads
some intersting questions
thread
Thread Q
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:29:43.