Best C# solution for multithreaded threadsafe read/write locking?

前端 未结 8 788
无人共我
无人共我 2021-01-01 05:08

What is the safest (and shortest) way do lock read/write access to static members in a multithreaded environment in C#?

Is it possible to do the thread

8条回答
  •  旧巷少年郎
    2021-01-01 05:59

    Locking in static methods sounds like a bad idea, for one thing if you use these static methods from class constructor you could run into some interesting side-effects due to loader locks (and the fact that class loaders can ignore other locks).

提交回复
热议问题