This question is from K&B
Solution:
D and F. D is correct because the wait() method is overloaded to accept a wait duration
in milliseconds. If the thread has not been notified by the time the wait duration has elapsed,
then the thread will move back to runnable even without having been notified. F is
correct because wait()/notify()/notifyAll() must all be called from within
a synchronized, context. A thread must own the lock on the object its invoking
wait()/notify()/notifyAll() on.
A is incorrect because wait()/notify() will not prevent deadlock. B is incorrect
because a sleeping thread will return to runnable when it wakes up, but it might not necessarily
resume execution right away. To resume executing, the newly awakened thread must still be
moved from runnable to running by the scheduler. C is incorrect because synchronization prevents
two or more threads from accessing the same object. E is incorrect because notify() is not
overloaded to accept a duration. G and H are incorrect because wait() and sleep() both
declare a checked exception (InterruptedException).
What I wan't to know is that...why g is not correct choice.Isn't it true that we get a runtime exception if wait and notify are not called from the synchronized block?