Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
matt love
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me more intuitive to think of each as instance methods.

Thanks.

Matt
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff.

Makes terrific sense.

Matt

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!