• Post Reply Bookmark Topic Watch Topic
  • New Topic

query on sleep() method  RSS feed

 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we call sleep(), it causes the running thread to transit to a ready to run state. Does the sleep() call will also relinquish the lock on the object if it is invoked from a synchronized method?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep:
When we call sleep(), it causes the running thread to transit to a ready to run state. [/QB]

By "Ready to run" state you are referring to a "New" state?
Sleep gets the thread into a TIMED_WAITING state.

(These thread states are defined in the enum java.lang.Thread.State)

Sandeep:Does the sleep() call will also relinquish the lock on the object if it is invoked from a synchronized method?

No it does not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!