This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Why are sleep(), yield() and interrupted() static? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Why are sleep(), yield() and interrupted() static?" Watch "Why are sleep(), yield() and interrupted() static?" New topic
Author

Why are sleep(), yield() and interrupted() static?

matt love
Ranch Hand

Joined: Jan 25, 2010
Posts: 67
It seems to me more intuitive to think of each as instance methods.

Thanks.

Matt
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Because they apply to the current thread. Certainly you wouldn't want just any thread to call sleep() or yield() on your thread. And you probably wouldn't want another thread to be able to clear your current thread's interrupted flag.

matt love
Ranch Hand

Joined: Jan 25, 2010
Posts: 67
Thanks Jeff.

Makes terrific sense.

Matt

 
Don't get me started about those stupid light bulbs.
 
subject: Why are sleep(), yield() and interrupted() static?
 
It's not a secret anymore!