Mutex lock: what does “blocking” mean?

后端 未结 4 735
日久生厌
日久生厌 2020-12-28 16:15

I\'ve been reading up on multithreading and shared resources access and one of the many (for me) new concepts is the mutex lock. What I can\'t seem to find out is what is ac

4条回答
  •  星月不相逢
    2020-12-28 16:29

    Blocking means just that. It is blocked. It will not proceed until able. You don't say which language you're using, but most languages/libraries have lock objects where you can "attempt" to take the lock and then carry on and do something different depending on whether you succeeded or not.

    But in, for example, Java synchronized blocks, your thread will stall until it is able to acquire the monitor (mutex, lock). The java.util.concurrent.locks.Lock interface describes lock objects which have more flexibility in terms of lock acquisition.

提交回复
热议问题