Set core pool size

pull/210/head
M66B 3 years ago
parent 65c49f3898
commit d23bd75e8d

@ -161,7 +161,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RunnableFuture; import java.util.concurrent.RunnableFuture;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -298,17 +297,14 @@ public class Helper {
// java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again // java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
// 1040 KB native stack size / 32 KB thread stack size ~ 32 threads // 1040 KB native stack size / 32 KB thread stack size ~ 32 threads
int processors = Runtime.getRuntime().availableProcessors(); // Modern devices: 8 int processors = Runtime.getRuntime().availableProcessors(); // Modern devices: 8
threads = Math.max(8, processors * 2);
}
if (threads == 0)
return new ThreadPoolExecutorEx( return new ThreadPoolExecutorEx(
name, name,
0, Integer.MAX_VALUE, processors + 1,
60L, TimeUnit.SECONDS, Math.max(8, processors * 2) + 1,
new SynchronousQueue<Runnable>(), 3L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
factory); factory);
else if (threads == 1) } else if (threads == 1)
return new ThreadPoolExecutorEx( return new ThreadPoolExecutorEx(
name, name,
threads, threads, threads, threads,

Loading…
Cancel
Save