Java Thread interrupted() methodThe 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. SyntaxReturnThis method will return true if the current thread has been interrupted otherwise returns false. ExampleTest it NowOutput: 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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India