Forums Register Login

S&B 1.5 Chapter 9, question 10

+Pie Number of slices to send: Send
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?

A. After object B is notified or after two seconds.
B. After the lock on B is released or after two seconde.
C. Two seconds after object B is notified
D. Two seconds after lock B is released.

A is correct: Either event will make the thread a candidate to get another turn at the CPU

Question I thought Threads were notified � not objects

Thanks
+Pie Number of slices to send: Send
 

Question I thought Threads were notified � not objects



I guess it is just a "wording" issue. Threads are notified, and I think is it safe to assume that "object B is notified" meant thread A is notified via a call to the notify() method of object B.

Henry
+Pie Number of slices to send: Send
Henry,

Thanks again. Yes I thought it was wording. Sometimes it is tricky knowing when the issue is wording vs substance!

Thanks again!
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 694 times.
Similar Threads
Thread states and Object lock
K & B question 6 chapter 9(Threads).
Thread Question
Wait with timeout
Doubt on wait method in Threads
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:03:59.