File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 18494

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: 6661

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
Don't get me started about those stupid light bulbs.
subject: Thread.yield() method - where do we call it
Similar Threads
Difference between run and start method of Thread
regarding thread run method
Why start() method