FAQ

Java

JSP

Servlet


Advertisement



What are the differences between interrupted() and isInterrupted() method of the Thread class?

There are some subtle differences between the Thread (Thread API Document) methods interrupted() and isInterrupted():

  • The interrupted() is a static method in Thread class that determines if the current thread has been interrupted. "The interrupted status of the thread is cleared by this method". Therefore, if a thread was interrupted, calling interrupted() once would return true, while a second call to it would return false until the current thread is interrupted again.
  • The isInterrupted() is an instance method that tests if this thread instance has been interrupted. "The interrupted status of the thread is unaffected by this method".


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |