Java SE API

Thread.interrupted()

Test and clear the current thread interrupt status.

Formal Syntax & Structure

java syntaxjava
static boolean interrupted()

Working Example

Example Snippetjava
import java.time.Duration;import java.util.concurrent.*;public class Main {
    public static void main(String[] args) throws Exception {        Callable<Integer> count = () -> 6 * 7;        System.out.println(count.call());        Thread.currentThread().interrupt();        System.out.println(Thread.currentThread().isInterrupted());        System.out.println(Thread.interrupted());        System.out.println(Thread.currentThread().isInterrupted());    }}
Java Reference