This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What puts a thread in a waiting state?

 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the following three methods could put a thread in a waiting state: wait(), sleep(), join(). Is this true?

I seem to remember something that states there's a sleeping state. Or is this a subset of waiting state?

What state does yield() cause for the currently executing thread?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yield puts a thread from running state back to runnable. From there the thread can go immediately back to running, or stay in runnable until it gets rescheduled to go back into running (that's because another thread gets a go at the cpu).
 
Robert Chisholm
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget that there is a "blocked on an object's lock" type of waiting that isn't so obvious.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic