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

IllegalMonitorStateException doubt

 
Deepak Borania
Ranch Hand
Posts: 45
  • 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: 20531
54
Chrome Eclipse IDE Java Windows
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic