imbajin commented on code in PR #144:
URL:
https://github.com/apache/incubator-hugegraph-commons/pull/144#discussion_r1680492563
##########
hugegraph-common/src/main/java/org/apache/hugegraph/util/ExecutorUtil.java:
##########
@@ -21,13 +21,58 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.LinkedBlockingQueue;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-
import org.apache.hugegraph.concurrent.PausableScheduledThreadPool;
+
+
public final class ExecutorUtil {
+ public static ThreadPoolExecutor newDynamicThreadExecutor(String name,
+ int corePoolSize,
+ int
maximumPoolSize) {
+
+ long keepAliveTime = 60L;
+ TimeUnit unit = TimeUnit.SECONDS;
+ ThreadFactory factory = new BasicThreadFactory.Builder()
+ .namingPattern(name)
+ .build();
+ CustomBlockingQueue<Runnable> workQueue = new CustomBlockingQueue<>();
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
+ corePoolSize,
+ maximumPoolSize,
+ keepAliveTime,
+ unit,
+ workQueue,
+ factory,
+ new ThreadPoolExecutor.CallerRunsPolicy() // 饱和策略
Review Comment:
enhance the comment (English & put in a single line)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]