• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

query on sleep() method

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic