线程绑定到指定CPU

参考:https://mp.weixin.qq.com/s/494wqyxyFzDuGwG_51tFbQ

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>affinity</artifactId>
            <version>3.20.0</version>
        </dependency>
    public static void main(String[] args) {

        try (AffinityLock affinityLock = AffinityLock.acquireLock(3)) {
            // do some work while locked to a CPU.
            while (true) {
            }
        }

    }

posted @ 2021-06-21 11:22  懒企鹅  阅读(118)  评论(0编辑  收藏  举报