• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait, notifyAll IllegalMonitorStateException

 
Maciej Kowalski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody

I am Java newbie (and mid-RoR developer).

I have a simple program.
Ball is shared amont players. Ball should be passed to random Player.

Ok here goes the code:



But it dont works.
I get exception: IllegalMonitorStateException.

How can I fix this?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're going to call X.wait() or X.notify() or X.notifyAll(), you have to be holding X's monitor (lock). That is, you have to be in a sync block that is synced on X.


 
Maciej Kowalski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:If you're going to call X.wait() or X.notify() or X.notifyAll(), you have to be holding X's monitor (lock). That is, you have to be in a sync block that is synced on X.




Thanks for the quick reply.

IT WORKS!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic