Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

API for wait question

 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a thread becames "notified" then API states

The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

Is there any possibilty that the synchonization state of the object is not "synchronized" before the call to wait?
The API doesn't explicity say that the monitor was adquired before calling wait. Any particular reason?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that's not possible. Object.wait() throws an IllegalMonitorStateException if you don't have a monitor lock on the object. See the Javadoc.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic