Hi All.... I am preparing for scjp 5.... in K&B book in chapter9 (Threads) . at the Q9 page 737 ...the K&B answer is (D: 12). but there are a possible situation in JVM called spontaneous wakeup that may be notify the waited thread even though NO CODE has called notify(),,, and this situation occured not always.... I think that the answer to be correct is Both (B:123 and C:12) Some expert tel me what is the exact answer and why? Please Help thanks
preparing scjp5 [ April 12, 2006: Message edited by: ali tareq ]
I don't know about "spontaneous wakeup" of a thread without the need of notify() method, but in exams i think we are suppose to select only those options which are guaranteed to occur always, not those which can or cannot happen depending on JVM.
Joined: Feb 16, 2006
Thanks Asha but i think that question need more enhancement if the question need to select all that apply...
"[...] The thread may be removed from the wait set due to any one of the following actions, and will resume sometime afterward."
An internal action by the implementation. Implementations are permitted, although not encouraged, to perform "spurious wake-ups" -- to remove threads from wait sets and thus enable resumption without explicit instructions to do so. Notice that this provision necessitates the Java coding practice of using wait only within loops that terminate only when some logical condition that the thread is waiting for holds. [...]"
Also because the term "necessitates" is used here, I *think* "123" should be a correct answer as well. Shouldn't the starting-point be the language specification instead of the "major JVM implementation(s)" (whatever those are)? [ October 28, 2006: Message edited by: P Boon ]