This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread.yield() method - where do we call it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread.yield() method - where do we call it" Watch "Thread.yield() method - where do we call it" New topic

Thread.yield() method - where do we call it

Charles Chikito
Ranch Hand

Joined: May 22, 2009
Posts: 76
Hello there,

Just wondering where we should call the yield() method.

In main() or run() ?

I guess in run(), correct me if I'm wrong.


Henry Wong

Joined: Sep 28, 2004
Posts: 19347

The thread that you want to yield should call the Thread.yield() method.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

It depends on which thread you want to yield(). Place the appropriate call there

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
I agree. Here's the link:
subject: Thread.yield() method - where do we call it