diff --git a/aio-pro/src/main/java/org/smartboot/socket/transport/Worker.java b/aio-pro/src/main/java/org/smartboot/socket/transport/Worker.java index 733591d9c356d3b6e8d1eed869ece6fce1719c35..f99efcbecf10eb8374030b8ba7556818d139c358 100644 --- a/aio-pro/src/main/java/org/smartboot/socket/transport/Worker.java +++ b/aio-pro/src/main/java/org/smartboot/socket/transport/Worker.java @@ -183,6 +183,9 @@ public final class Worker implements Runnable { return true; } + private static final Long timeout = 1000L; + + private static final TimeUnit timeUnit = TimeUnit.MILLISECONDS; void shutdown() { try { @@ -193,8 +196,9 @@ public final class Worker implements Runnable { selector.wakeup(); executorService.shutdown(); try { + executorService.awaitTermination(timeout, timeUnit); selector.close(); - } catch (IOException e) { + } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } }