Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static int getDefaultThreadPoolSize() { return getDefaultThreadPoolSize(8); } public static int getDefaultThreadPoolSize(int max) { int availableProcessors = 2 * Runtime.getRuntime().availableProcessors() + 1; return availableProcessors > max ? max : availableProcessors; } }