This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why are sleep(), yield() and interrupted() static?
 
jQuery in Action, 3rd edition