"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Nigel Shrin wrote:'notify' will make runnable a waiting thread, but a sleeping thread will always sleep it's time?
There is no method to wake a sleeping thread?
thank you
Ah - might have found the answer:
you can use an interrupt(), but have to handle/declare an interrupt exception
notify() and notifyAll() methods will notify the Threads, which are waiting for execution, in the pool. I think it's correct thet we can call interrupt() method to interrupt that sleeping thread. But don't have any example coding!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:notify() and notifyAll() methods will notify the Threads, which are waiting for execution, in the pool. I think it's correct thet we can call interrupt() method to interrupt that sleeping thread. But don't have any example coding!
Waiting and sleeping are two different things. notify and notifyAll won't wake up a sleeping thread. Only the interrupt method can be used to wake a sleeping thread...