public class Test { public static void main(String[] args) { // 获取当前CPU的核数 System.out.println(Runtime.getRuntime().availableProcessors()); } }