package shop.alien.util.thread;

import shop.alien.util.system.CpuInfoUtil;

/**
 * 线程工具类
 *
 * @author ssk
 * @version 1.0
 * @date 2024/9/12 10:50
 */
public class ThreadUtil {

    public static void main(String[] args) {

        //根据cpu核心数打开指定个数线程
        int cpuCoreCount = CpuInfoUtil.getCpuCoreCount();
        for (int i = 0; i < cpuCoreCount; i++) {
            int threadCount = i + 1;
            MyRunnable run = new MyRunnable("线程: " + threadCount);
            Thread thread = new Thread(run);
            thread.start();
        }
    }
}

