Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java library provides a rich set of API methods to control the behavior of threa

ID: 3841906 • Letter: J

Question

Java library provides a rich set of API methods to control the behavior of thread. For example, we can specify when a start when exactly a thread can put into the sleep state, and when a thread w terminate. True False 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 thread become a candidate to get another turn at the CPU? After the lock on Bis released, or after two seconds After object B is notified, or after two seconds Two seconds after object Bis notified Two seconds after lock B is released

Explanation / Answer

Answer71 false Java Threads are OS dependent i.e. Scheduling varries from OS to OS, that's why we have limited privileges to alter the behaviour of threads in java

Answer 72 Option b will be the answer

For running again the notification or wait time expiration event will make the thread become a candidate.

Option A is not a correct answer as unless a notification occurs, a waiting thread will not return to runnable when the lock is released, unless a notification occurs.

Option C is not correct 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.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote