Is it possible to wake up a sleeping thread?

Gautam Marwaha

[I have a thread which is sleeping for a long period of time.Another object has the object of this sleeping thread. In some event , the second object wants to wake up the sleeping thread before its due time for sleeping is completed. I would call it "resuming a sleeping thread". Is this possible or allowed in java?]

Call
sleepingThread.interrupt()

[This will generate an InterruptedException. Now you know why you have to catch InterruptedException every bl**dy time you call Thread.sleep! -Alex]

About | Sitemap | Contact