Java Thread currentThread() method

The currentThread() method of thread class is used to return a reference to the currently executing thread object.

Syntax

Return value

It returns the currently executing thread.

Example

Test it Now

Output:

Thread-0
Thread-1





Latest Courses