diff options
| author | 2026-07-05 07:09:56 +0200 | |
|---|---|---|
| committer | 2026-07-09 09:59:28 +0200 | |
| commit | 0bb4af1f0db9bec0590c7bdccb9fe8b99d15d795 (patch) | |
| tree | ba745c143e4d1d2a832cc1412dbd3fc70f19c361 /src/main/java/com/it_jaros/jscanner/App.java | |
| parent | 08f8b980b6c2ed8e8cf284e74230c0adf78b0e64 (diff) | |
Improved shutdown logic that finally works properly
Now if the user quits, then the main thread continues to collect
all available results
the producer and the host scan port threads close as soon as
they check the flag and return whatever they have till now
Diffstat (limited to 'src/main/java/com/it_jaros/jscanner/App.java')
| -rw-r--r-- | src/main/java/com/it_jaros/jscanner/App.java | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/main/java/com/it_jaros/jscanner/App.java b/src/main/java/com/it_jaros/jscanner/App.java index 8fa3cca..700b3f0 100644 --- a/src/main/java/com/it_jaros/jscanner/App.java +++ b/src/main/java/com/it_jaros/jscanner/App.java @@ -1,17 +1,14 @@ package com.it_jaros.jscanner; -import java.time.Duration; import java.util.BitSet; import java.util.List; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; public class App { private static Thread shutdownHook; private static final CountDownLatch shutdownLatch = new CountDownLatch(1); - private static final int shutdownTimeoutInMillis = 5000; public static void main(String[] args) { try { @@ -113,10 +110,7 @@ public class App { private static void shutdown(Scanner scanner) { try { scanner.cancel(); - if (!scanner.awaitTermination(Duration.ofMillis(shutdownTimeoutInMillis))) { - scanner.cancelNow(); - } - shutdownLatch.await(shutdownTimeoutInMillis, TimeUnit.MILLISECONDS); + shutdownLatch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { |
