PDF
线1Java(2)ThreadPoolExecutorContents线 .......................................................................................... 1线线 .................................................................................................. 2使线线线使线线线线线线线线# cat /proc/sys/kernel/threads-max15734# ulimit -vunlimitedmax_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);线JVM线线java.lang.OutOfMemoryError: unable to create new native thread线线-Xss线线 线2线-Xmx线2 mb --> 5744 threads4 mb --> 5743 threads...768 mb --> 3388 threads1024 mb --> 2583 threads线线线线使pthread_create线使mmap线线使线使线线ThreadPoolExecutor线public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, Executors.defaultThreadFactory(), defaultHandler);}CorePoolSize / MaximumPoolSize线线线线线线线线使Executors.newFixedThreadPoolpublic static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, 线3 new LinkedBlockingQueue<Runnable>());}线线使prestartCoreThreadprestartAllCoreThreadsKeep-alive 线线Long.MAX_VALUE线线线使allowCoreThreadTimeOutworkQueue线线线线使使SynchronousQueue线使使LinkedBlockingQueue线线使ArrayBlockingQueue线线

HTML view coming soon.

Download PDF for the full formatted version.