Why does the lock object have to be static?

前端 未结 3 2102
别那么骄傲
别那么骄傲 2020-11-28 02:33

It is very common to use a private static readonly object for locking in multi threading. I understand that private reduces the entry points to the locking object by tighten

3条回答
  •  执笔经年
    2020-11-28 03:06

    The scope and lifetime of a lock can/should depend on the 'thing' you want to lock. Static locks are mostly used to lock static things.

提交回复
热议问题