aspose file tools
The moose likes Beginning Java and the fly likes doubt in sleep() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "doubt in sleep() method " Watch "doubt in sleep() method " New topic
Author

doubt in sleep() method

manas ranjan mandal
Ranch Hand

Joined: Apr 02, 2008
Posts: 97
why sleep() method in Thread class is static?why is the reason behind to made is a static method?
thanks in advance
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32599
    
    4
Presumably so you can access it without knowing the name of the thread you are running on.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

If it were an instance method then you could cause other threads to sleep, by calling their sleep() method. That would be a bad thing.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: doubt in sleep() method
 
Similar Threads
if method is on Stack and object is on heap then where do Static method is stored
override sleep method
How to use sleep ?.
sleep method
Threads