• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

The conflicting answers for these 2 questions!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think those questions get all tangled up with the exact meaning of "directly cause" and are therefore worthless.
Bill
 
Richard Yi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many appreciate Sudhakar! Your explanation is so clear that I catch it completely.
 
I think she's lovely. It's this tiny ad that called her crazy:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic