Does the Java: thread give up cpu when it is blocked by synchronized, reentrantlock, etc.?

see that there is a saying that the thread usually gives up cpu

Thread.currentThread().yield();
IO
Sleep,  wait

so does the thread give up cpu when it is blocked by synchronized, reentrantlock, etc.?

Nov.15,2021

what to do on a single core without cpu,? isn't there a deadlock?


not necessarily. Jvm uses some lock optimization strategies, such as spin locks, so cpu will not be abandoned.
if the spin time is up and the lock is still not acquired, the real cpu blocking will be abandoned.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7be422-1dbb4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7be422-1dbb4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?