• Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalMonitorStateException doubt  RSS feed

 
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
Posts: 21092
85
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!