Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Find out how many cores are available to the JVM. * */ public static int getCoreCount() { int retval = Runtime.getRuntime().availableProcessors(); if (retval > 4) { retval = 4; } return retval; } }