Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4014736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:31:59+00:00 2026-05-20T09:31:59+00:00

In javadoc there is said that yield method Causes the currently executing thread object

  • 0

In javadoc there is said that yield method

Causes the currently executing thread object to temporarily pause and allow other threads to execute.

And Katherine Sierra and Bert Bates SCJP book says that

yield() is supposed to do is
make the currently running thread head back to runnable to allow other threads of
the same priority to get their turn.

So what actually method is doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:31:59+00:00Added an answer on May 20, 2026 at 9:31 am

    Given a multi-threaded application, yield will cause the currently executing thread to pause execution and be set in a waiting state. The JVM will then begin running another thread that was previously in a waiting state.

    I believe the same thread that just yielded could technically be scheduled to start again.

    And I have yet to see this in the wild though. So I think it is safe to avoid.

    To elaborate:

    In a multi-threaded environment threads are scheduled and unscheduled off and on at the JVM’s will. So, even if yield is not called in code, your thread can/will automatically yield to other threads when the JVM decides it should. This allows multi-threading to work in an environment with only one processing core.

    Calling yield simply tells the JVM to put the current thread in a waiting state even if the JVM wasn’t going to.

    I shall attempt an illustration:
    The following is a very simplified illustration of the execution of 2 threads over time (assume 1 core)-

    Thread\Time    1    2    3    4    5    6    7    8    9
    Thread 1    -----------       -----          -------
    Thread 2               -------     ----------       ------
    

    Whenever you see a '-' that means a thread is executing. A ' ' means that the thread is waiting. As you can see, only 1 thread can actually run at a time. So, while 1 runs, the other waits. What yield is intended to do is give other threads a chance to run ahead of the currently running thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the Javadoc of WeakHashMap.html , it said Each key object in a WeakHashMap
I have a javadoc doclet that requires an additional jar file to be on
I was reading the Math.random() javadoc and saw that random is only psuedorandom. Is
Can Thread.getContextClassLoader() be null ? The javadoc is not really clear. Should a library
Is there a JavaDoc style sheet? The default one is pretty ugly.
Is there a Javadoc for JSON.simple?
There is JavaDoc of a normal Java API with an English edition and a
Is there such a thing as Javadoc-type documentation available for C/C++ libraries?
I know that there is @inheritDoc , but it's only for methods which override
Maybe I'm being picky, but in javadoc there is a following information about LinkedHashSet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.