Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Commit 76fcfac

Browse files
committed
Added .checkInterrupted() to Runners
1 parent 2cac996 commit 76fcfac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/io/scalecube/runners/Runners.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ public static void onShutdown(Runnable runnable) {
1919
Signal.handle(new Signal("INT"), handler);
2020
Signal.handle(new Signal("TERM"), handler);
2121
}
22+
23+
/**
24+
* Utility method to simply check if current thread is interrupted. If it is, then {@code
25+
* IllegalStateException} is being thrown.
26+
*/
27+
public static void checkInterrupted() {
28+
if (Thread.currentThread().isInterrupted()) {
29+
throw new IllegalStateException("Unexpected interrupt");
30+
}
31+
}
2232
}

0 commit comments

Comments
 (0)