aspose file tools
The moose likes Beginning Java and the fly likes IllegalMonitorStateException doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "IllegalMonitorStateException doubt" Watch "IllegalMonitorStateException doubt" New topic
Author

IllegalMonitorStateException doubt

Deepak Borania
Ranch Hand

Joined: Jul 28, 2009
Posts: 45
GIven the following code :


Can someone please tell me why does the above code result in IllegalMonitorStateException at runtime?

And please explain a little about synchronized code blocks. I just can't seem to get hang of them.

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You synchronize on whatever.class, then try to get the lock on "this". You can only call wait, notify and notifyAll on objects you synchronize on.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: IllegalMonitorStateException doubt
 
Similar Threads
Thread -IllegalMonitorStateException and IllegalThreadStateException
wait( ) method behind the scene ...
problem with wait()- notify()
IllegalMonitorStateException from notify()
wait() and notifyAll()