1、lock、Monitor
lock(obj){}
编译之后是如下代码
Monitor.Enter(obj); try { // } finally { Monitor.Exit(obj); }
2、SemaphoreSlim
3、(Async)ManualResetEvent、(Async)AutoResetEvent
4、分布式锁(zk、redis)
微软文档:https://docs.microsoft.com/en-us/dotnet/standard/threading/threading-objects-and-features