Skip to content

Commit 5b8e84b

Browse files
khatwaniNikhilpivovarit
authored andcommitted
Refaactoring-Thread Interrupt (eugenp#3412)
1 parent 0a343e1 commit 5b8e84b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎core-java-concurrency/src/main/java/com/baeldung/concurrent/stopping/ControlSubThread.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public void run() {
4343
try {
4444
Thread.sleep(interval);
4545
} catch (InterruptedException e) {
46-
// no-op, just loop again
47-
}
46+
Thread.currentThread().interrupt();
47+
System.out.println("Thread was interrupted, Failed to complete operation");
48+
}
4849
// do something
4950
}
5051
stopped.set(true);

0 commit comments

Comments
 (0)