MCPcopy Create free account
hub / github.com/e2wugui/zeze / newFixedThreadPool

Method newFixedThreadPool

ZezeJava/ZezeJava/src/main/java/Zeze/Util/Task.java:89–101  ·  view source on GitHub ↗
(int threadCount, @NotNull String threadNamePrefix)

Source from the content-addressed store, hash-verified

87
88 // 固定数量的线程池, 普通优先级, 自动优先使用支持虚拟线程(不限制数量), 用于处理普通任务
89 public static @NotNull ExecutorService newFixedThreadPool(int threadCount, @NotNull String threadNamePrefix) {
90 if (USE_UNLIMITED_VIRTUAL_THREAD && isVirtualThreadEnabled()) {
91 try {
92 var es = (ExecutorService)Executors.class.getMethod("newVirtualThreadPerTaskExecutor",
93 (Class<?>[])null).invoke(null, (Object[])null);
94 logger.info("newFixedThreadPool({},{}) use unlimited virtual thread pool", threadCount, threadNamePrefix);
95 return es;
96 } catch (ReflectiveOperationException ignored) {
97 }
98 }
99 return Executors.newFixedThreadPool(threadCount,
100 new ThreadFactoryWithName(threadNamePrefix, Thread.NORM_PRIORITY, USE_VIRTUAL_THREAD));
101 }
102
103 // 关键线程池, 不使用虚拟线程时设为普通优先级+2, 线程数按需增长, 用于处理关键任务, 比普通任务的处理更及时
104 public static @NotNull ExecutorService newCriticalThreadPool(@NotNull String threadNamePrefix) {

Callers 6

mainMethod · 0.95
_runMethod · 0.95
mainMethod · 0.95
tryInitThreadPoolMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95

Calls 3

getMethodMethod · 0.80
invokeMethod · 0.65

Tested by 3

mainMethod · 0.76
_runMethod · 0.76
mainMethod · 0.76