This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Waking up a sleeping thread? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Waking up a sleeping thread?" Watch "Waking up a sleeping thread?" New topic
Author

Waking up a sleeping thread?

huny chopra
Greenhorn

Joined: Sep 17, 2007
Posts: 2
Can we wake up a sleeping thread before its sleeping time elapses?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hi, welcome to the ranch!

The Thread sleep() doc gives a good hint ... it can throw an interrupted exception if another thread interrupts it. That's what you need. Let's say MyRunnable sleeps at some point and we want to wake it up:

See if you can make something like that run. Let us know how it goes!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
jQuery in Action, 2nd edition
 
subject: Waking up a sleeping thread?
 
Similar Threads
WA #1.....word association
threads
True/False?
Thread States ?'s
synchronization - cannot wake a sleeping thread?