Multithreading – reentry locking: advantages and disadvantages?

Under what circumstances do people want to use turn back locks and ordinary locks?

Solution

I think reentrant locks have some extra overhead compared to ordinary locks - checking the thread that is acquiring the lock

Therefore, if you know that under normal operation, a thread will only acquire a lock once before releasing it again, you can get some performance by using normal locking This is particularly useful in tight loops, etc

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>