Java Programming - Threads - Discussion
Discussion Forum : Threads - General Questions (Q.No. 12)
12.
Assume the following method is properly synchronized and called from a thread A on an object B:
wait(2000);
After calling this method, when will the thread A become a candidate to get another turn at the CPU?
Answer: Option
Explanation:
Option A. Either of the two events (notification or wait time expiration) will make the thread become a candidate for running again.
Option B is incorrect because a waiting thread will not return to runnable when the lock is released, unless a notification occurs.
Option C is incorrect because the thread will become a candidate immediately after notification, not two seconds afterwards.
Option D is also incorrect because a thread will not come out of a waiting pool just because a lock has been released.
Discussion:
4 comments Page 1 of 1.
Ashish said:
1 decade ago
If Thread A is notified first, can it get CPU turn before the expiration of 2 sec?
D.raj said:
1 decade ago
Either of the two events (notification or wait time expiration) will make the thread become a candidate for running again.
Dinesh said:
1 decade ago
Give me an explanation that how it works?
Vibhor said:
1 decade ago
Please give me more explanation about this question.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers