未验证 提交 452a5f24 编写于 作者: B Boyang Jerry Peng 提交者: GitHub

Await thread pool termination when closing Pulsar client (#7962)

Co-authored-by: NJerry Peng <jerryp@splunk.com>
上级 c7ac08b1
......@@ -25,10 +25,13 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ExecutorProvider {
private final int numThreads;
private final List<ExecutorService> executors;
......@@ -49,6 +52,13 @@ public class ExecutorProvider {
}
public void shutdownNow() {
executors.forEach(executor -> executor.shutdownNow());
executors.forEach(executor -> {
executor.shutdownNow();
try {
executor.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.warn("Shutdown of thread pool was interrupted");
}
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册