This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Waking up a sleeping thread?" Watch "Waking up a sleeping thread?" New topic

Waking up a sleeping thread?

huny chopra

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
Don't get me started about those stupid light bulbs.
subject: Waking up a sleeping thread?
It's not a secret anymore!