The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What puts a thread in a waiting state? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What puts a thread in a waiting state?" Watch "What puts a thread in a waiting state?" New topic

What puts a thread in a waiting state?

Louie van Bommel
Ranch Hand

Joined: Aug 17, 2004
Posts: 76
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

Joined: Aug 03, 2002
Posts: 7729
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).

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Robert Chisholm
Ranch Hand

Joined: Jul 18, 2004
Posts: 69
Don't forget that there is a "blocked on an object's lock" type of waiting that isn't so obvious.

SCJP 1.4<br />(WIP) SCJD B&S v2.3.3
I agree. Here's the link:
subject: What puts a thread in a waiting state?
It's not a secret anymore!