• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

an exception about thrad

 
Paul Sun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I use wait(), I get the following exception
java.lang.IllegalMonitorStateException: current thread not owner
Could someone tell me the reason?
Thank you.
Paul
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sun:
When I use wait(), I get the following exception
java.lang.IllegalMonitorStateException: current thread not owner
Could someone tell me the reason?

You are going to have to put it in a synchronized block or method depending on what you are waiting on... of you are just calling wait() you are really doing this.wait() and that line needs to be in a synchronized method like I said above or in a block like this...

and it will probably need to be in a try-catch to catch InteruptedExceptions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic