feat(all): tune single Thread into SingleThreadExecutor by halibobo1205 · Pull Request #5410 · tronprotocol/java-tron

@halibobo1205

@halibobo1205 halibobo1205 changed the title feat(*): tune single Thread into SingleThreadExecutor feat(all): tune single Thread into SingleThreadExecutor

Aug 9, 2023

@halibobo1205

@halibobo1205

xxo1shine

if (!pool.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {
pool.shutdownNow(); // Cancel currently executing tasks
// Wait a while for tasks to respond to being cancelled
if (!pool.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are two waits of 60s, will the 60s time be too long?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

60s is the maximum value to be waited until the pool stops, if it doesn't, the pool may have a problem executing the task and needs to be fixed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (CommonParameter.getInstance().isJsonRpcFilterEnabled()) {
Thread filterProcessThread = new Thread(filterProcessLoop);
filterProcessThread.start();
filterEs = ExecutorServiceManager.newSingleThreadExecutor(filterEsName, true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDaemon original default value is false

}
logger.info("DPoS task stopped.");
ExecutorServiceManager.shutdownAndAwaitTermination(produceExecutor, name);
logger.info("DPoS task shutdown complete");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the thread shutdown log be printed in the function shutdownAndAwaitTermination?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Great!

tomatoishealthy

@codecov-commenter

jwrct