aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes IllegalMonitorStateException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IllegalMonitorStateException " Watch "IllegalMonitorStateException " New topic
Author

IllegalMonitorStateException

Karin Paola Illuminate
Ranch Hand

Joined: Oct 18, 2002
Posts: 109
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 ]

I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
in my opinion, it is true.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
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
 
subject: IllegalMonitorStateException