Java Thread yield() method

The yield() method of thread class causes the currently executing thread object to temporarily pause and allow other threads to execute.

Syntax

Return

This method does not return any value.

Example

Test it Now

Output:

main in control
main in control
main in control
Thread-0 in control
Thread-0 in control
Thread-0 in control
Thread-1 in control
Thread-1 in control
Thread-1 in control





Latest Courses