Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalMonitorStateException

 
Karin Paola Illuminate
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came accross the following question on the www.jsdiscuss.com site.
What happens when a method calls wait() without ensuring that the current thread owns the monitor of the object

Is it true that it may not throw the IllegalMonitorStateException if it owns the monitoring, because it says without ensuring?
[ March 27, 2003: Message edited by: Karin Paola Illuminate ]
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my opinion, it is true.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it true that it may not throw the IllegalMonitorStateException if it owns the monitoring,

First we look up the exception in the Java API documentation:
public class IllegalMonitorStateException
extends RuntimeException
Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor.

The exception is thrown to indicate the thread does not own the monitor.
Therefore, if the exception is thrown, the thread does not own the monitor.
Therefore, if the thread owns the monitor, the exception will not be thrown.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic