Does thread.yield() lose the lock on object if called inside a synchronized method?

前端 未结 3 472
感情败类
感情败类 2020-12-15 11:19

I understand that Thread.currentThread().yield() is a notification to thread scheduler that it may assign cpu cycle to some other thread of same priority if any

3条回答
  •  粉色の甜心
    2020-12-15 11:29

    No. Thread.yield() is not like Object.wait(). It just gives up control to allow a thread switch. It will have no effect on the concurrency of your program.

    There is no guarantee which thread the scheduler will run after a yield.

提交回复
热议问题