Why are sleep(), yield() and interrupted() static?
matt love
Ranch Hand
Joined: Jan 25, 2010
Posts: 62
posted
0
It seems to me more intuitive to think of each as instance methods.
Thanks.
Matt
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3133
posted
0
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: 62
posted
0
Thanks Jeff.
Makes terrific sense.
Matt
subject: Why are sleep(), yield() and interrupted() static?