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