Javatpoint Logo
Javatpoint Logo

Java Thread interrupted() method

The interrupted() method of thread class is used to check whether the current thread has been interrupted or not. This method clears the interrupted status of the thread that means if this method was to be called twice in succession, the second call would return false. If the interrupt status of a thread is true, this method will set the status to false.

Syntax

Return

This method will return true if the current thread has been interrupted otherwise returns false.

Example

Test it Now

Output:

is thread t1 interrupted..: false
is thread t1 interrupted..: false
is thread t2 interrupted..: false
doing task....: 1
doing task....: 2
doing task....: 3
doing task....: 1
doing task....: 2
doing task....: 3

Next TopicJava Thread





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA