摘要: //定义原子变量 int mituxInt = -1; //原子级别+1值,如果>=0,说明当前锁为空,可以执行,避免重复执行 if (Interlocked.Increment(ref mituxInt) <= 0) { if (_serverThread == null || (_serverThread.IsAliv... 阅读全文
posted @ 2018-09-19 16:49 多放辣椒 阅读(880) 评论(2) 推荐(0) 编辑
摘要: 先看看为什么要用锁 需求:多线程处理值的加减 static int NoLockData = 0; public static void NoLockNormalTest(int threadIndex) { while (true)//这是脑残设计,while(true) { //lock (lo 阅读全文
posted @ 2018-09-19 16:29 多放辣椒 阅读(2888) 评论(1) 推荐(0) 编辑