Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in sleep() method

 
manas ranjan mandal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably so you can access it without knowing the name of the thread you are running on.
 
Paul Clapham
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic