Skip to content

Commit

Permalink
misc: 重新限制用于查询的线程数不超过16个
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 14, 2024
1 parent 4a6c859 commit f2d77f2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public static ExecutorService executor()

MorphPlugin.getInstance()
.getSLF4JLogger()
.info("Creating new executor with a maximum of " + getThreadCount() + " thread(s) for profile lookup.");
.info("Creating new executor with a maximum of " + getMaximumThreadCount() + " thread(s) for profile lookup.");
}

return executor;
}

private static int getThreadCount()
private static int getMaximumThreadCount()
{
return Math.max(4, Runtime.getRuntime().availableProcessors() / 2);
return Math.min(16, Math.max(4, Runtime.getRuntime().availableProcessors() / 2));
}

private static ExecutorService createExecutor()
{
return Executors.newFixedThreadPool(getThreadCount(), new ThreadFactory()
return Executors.newFixedThreadPool(getMaximumThreadCount(), new ThreadFactory()
{
private final AtomicInteger threadCount = new AtomicInteger(0);

Expand Down

0 comments on commit f2d77f2

Please sign in to comment.