onspinwait专题

Thread.onSpinWait()有什么作用?为什么要睡眠0毫秒?

概述 今天在整理之前学习资料时,偶然看见之前自己写的demo: public class MyTest {static volatile boolean temp = true;public static void main(String[] args) throws InterruptedException {Thread thread = new Thread(() -> {while (