Why must threads wait and wake up locked?

when any thread X executes the wait () and notify () methods on any thread Y, it needs to acquire the lock first.
it is said that the locking mechanism is to solve the critical resource problem, so does it allow threads to start and pause access to any critical resources? Can
wait and wake up threads in a way similar to interrupts and messages instead of locks?
Please don"t hesitate to give me advice.


wait () and nitify () are used to solve the problem of critical resources. If a critical resource is in a thread and the thread cannot execute for other reasons, we need to wait (), the critical resource so that other threads can call the critical resource.
if, as you say, it is not a critical resource, then you do not need to use the wait method, because it does not affect other threads, and other threads will not block at all


waiting and waking up objects are critical resources, otherwise why should the thread wait, right?

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-1b30c78-2bd3a.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-1b30c78-2bd3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?