Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What puts a thread in a waiting state?  RSS feed

 
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!