• 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

What happens to the locks if the JVM takes thread from running to runable?

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've read what certain methods that change the threads state do with the locks. Wait gives up the locks, sleep and yield do not. But what happens to the locks a thread has if the JVM takes it out of running and into the runnable state? It keeps them I guess, to get on running like it was running if the JVM puts it in the running state again?
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt moving from running to runnable would do anything to the locks. Runnable means that the thread has everything it needs and is ready for running when ever the scheduler decides to start execution. And that includes locks.
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Wentink:
Wait gives up the locks, sleep and yield do not.

Small addition. wait gives up the lock on the object, on which wait is called. All other locks are still held by the thread.
 
reply
    Bookmark Topic Watch Topic
  • New Topic