Home » Java Thread isInterrupted() Method with Examples

Java Thread isInterrupted() Method with Examples

by Online Tutorials Library

Java Thread isInterrupted() method

The isInterrupted() method of thread class is an instance method that tests whether the thread has been interrupted. It returns the value of the internal flag either true or false. If the thread is interrupted then it will return true otherwise false.

Syntax

Return

It will return true if the thread has been interrupted otherwise returns false.

Example

Test it Now

Output:

is thread interrupted..: false  is thread interrupted..: false  is thread interrupted..: true  is thread interrupted..: false  doing task....: 1  doing task....: 2  doing task....: 3  doing task....: 1  doing task....: 2  doing task....: 3  

Next TopicJava Thread

You may also like