diff --git a/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java b/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java index 58dcf99aa4..566232a1bd 100644 --- a/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java +++ b/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java @@ -87,6 +87,11 @@ public CompletableFuture submit(Runnable task) { public void execute(Runnable task) { check(); tasks.add(task); + if (shutdown.get()) { + if (tasks.remove(task)) { + throw new IllegalStateException("EventLoop is shutdown"); + } + } } public CompletableFuture shutdownGracefully() {