What is the Thread.State of a thread after Thread.yield()?

concurrency, java

Solution

No, the thread will still be in the `RUNNABLE` state. Note that `RUNNABLE` signifies that a thread is available to be run and may be either currently running or waiting its turn. `Thread.STATE` does not distinguish between a thread that is currently executing and a thread that is ready to run, they are both `RUNNABLE`.

A thread will only enter the `WAITING` state when either `wait()`, `join()` or `LockSupport.park()` has been called.

By calling `Thread.yield()` method the currently running thread is voluntarily giving up its slice of CPU time. This thread then goes from running back into a ready state.

Problem

What is the `Thread.State` of a thread after `Thread.yield()` ? Is it a `Thread.State.WAITING`? Thanks.

Original source