What is the reason for “locks are an expensive operation” to be uttered so often?

前端 未结 5 2050
野趣味
野趣味 2021-02-08 01:18

I have read a lot of material on threading, and all the synchronization mechanisms involved. I also understand the dangers of not doing it properly.

I just watched th

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-08 01:34

    Locks are often spinlocks, which cause a thread to "spin" doing no useful work when the lock is taken.

    Doing nothing is expensive, since, as everyone knows: "time is money".

提交回复
热议问题