Below are the 2 questions regarding thread, and in parentheses are the standard answers provide to me: 55. Which two CANNOT directly cause a thread to stop executing? (Choose Two) (A,E) A. Calling the yield method B. Calling the wait method on an object C. Calling the notify method on an object D. Calling the NotifyAll method on an object E. Calling the start method on another Thread object 60. Which two CANNOT directly cause a thread to stop executing? (Choose Two) (A,C) A.Existing from a synchronized block B.Calling the wait method on an object C.Calling notify method on an object D.Calling read method on an InputStream object E.Calling the SetPriority method on a Thread object You should note that the question is the same but the items for choosing are different. Also you should note that the "notify" was chosen as answer in the latter but not in the former! This is so strange and conflict and I cannot understand! According my knowledge, I think yield(), wait() and read()(I/O block) could cause a thread to stop directly, but notify() and notifyAll() should wake a thread up and start() is the method let the method run! But the above answers frustrate me! Maybe I'm confusing regarding this conception, would you pls help me and give me the detailed and clear explanation for each item enumerated above? Are there some errors in standard answers? Thank you very much!
Joined: Jun 02, 2003
Richard, According to me all the answers provided are wrong, Here's my explanation First, my understanding of STOP a thread is not runnable but still alive Q55. yield - MAY cause the thread to stop if we have more threads of the same priority wait - will cause the thread to stop/move out of runnable state notify - will NOT cause a thread to stop (correct ans) notifyall - will NOT cause the thread to stop(correct ans) start - the thread is in the runnable state (but MAY BE not running) Hence according to me the correct answers are C,D Q60. Exit synchornized - Cannot cause a thread to stop(correct ans) wait - will cause the thread to stop/move out of runnable state notify - will NOT cause a thread to stop (correct ans) read method - may or may not cause the thread to stop setpriority - if the priority is lowered and higher priority thread is in runnable state then the current thread may be pre-empted. So the correct answers are A,C Hope this helps -S
Author and all-around good cowpoke
Joined: Mar 22, 2000
I think those questions get all tangled up with the exact meaning of "directly cause" and are therefore worthless. Bill