Are Thread.sleep(0) and Thread.yield() statements equivalent?

后端 未结 12 1755
太阳男子
太阳男子 2020-11-27 02:42

Are these two statement equivalent?

Thread.sleep(0);
Thread.yield();
12条回答
  •  旧时难觅i
    2020-11-27 03:22

    Yield adds the current thread to the ready queue and allows other threads to run. Sleep is not guaranteed to relinquish the cpu.

提交回复
热议问题