File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalMonitorStateException doubt

 
Deepak Borania
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic