Java – InterruptedException
InterruptedException: Thrown when a thread is interrupted while it is waiting, sleeping, or performing some other activity.
Example:
Thread thread = new Thread(() -> {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("Caught InterruptedException: " + e.getMessage());
}
});
thread.start();
thread.interrupt();
No images available.