Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread wait

 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true. Select all correct answers.
A.The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.
B.The wait(), notify(), and notifyAll() methods must be executed in synchronized code.
C.The notify() and notifyAll() methods can be used to signal and move waiting threads to ready-to-run state.
D.The Thread class is an abstract class
Correct answers are: B and C. Why isn't A true?
Shashi
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait() is defined in java.lang.Object. It's purpose is to allow any object (not necessarily a threaded one) to protect its internal data against "unordered" access.
 
parag bharambe
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
wait() method is used to used to move the thread from runnig state to ready to run state. So IMO this is same as putting a current thread in waiting state.
SO i think A is also right ans.
Am i right? !
Parag
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point is that A says " defined in the Thread class". Therefore A is NOT right. No matter what the rest of the statement says.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic