How to cancel Object.wait()

Hello,

I have some methods where I am using myObject.wait() to pause them. The only way I can continue is if I call myObject.notify() which continues the program at that point. So basically this is behaving like a 'pause' right now.

What i need is a way to cancel the execution of myObject.wait() so that it doesn't proceed with the logic after that. Is there something I can do for this?

Thanks

[425 byte] By [desimundaa] at [2007-11-27 1:41:13]
# 1
Have a flag to indicate whether or not to continue. Set the flag to indicate whether not to continue before calling notify. You might also use a java.util.concurrent.locks.Condition for the purpose, though a simple flag might be easier if you're already doing the wait etc.
pm_kirkhama at 2007-7-12 0:56:22 > top of Java-index,Java Essentials,Java Programming...
# 2
That's a good idea, I could try that. How about using Thread.currentThread().interrupt();Is there I can uniquely identify a thread name for each of the methods and then make a call to that thread to interrupt it?
desimundaa at 2007-7-12 0:56:22 > top of Java-index,Java Essentials,Java Programming...