mutex lock priority

后端 未结 5 1517
闹比i
闹比i 2021-01-14 02:58

In multithreading (2 thread) program, I have this code:

while(-1)
{
    m.lock();

    (...)

    m.unlock();
}

m is a mutex (

5条回答
  •  无人共我
    2021-01-14 03:43

    It's not a good idea to rely on such code, so you should probably change your design. However, on some operating systems, sleep(0) will yield the thread. (Sleep(0) on Windows) Again, it's best not to rely on this.

提交回复
热议问题