多线程
夜风可知冷
还是个菜鸟,学习阶段
展开
-
关于使用Mutex类来实现线程同步
using System;using System.Threading;namespace ThreadDemo_Mutex{ class Program { static void Main(string[] args) { const string MutexName = "CSharpThreadingCook...翻译 2019-03-08 14:12:46 · 296 阅读 · 0 评论 -
使用SemaphoreSlim类(作为Semaphore类的轻量级版本)控制同时访问同一资源的线程数量
using System;using System.Threading;namespace ThreadDemo_SemaphoreSlim{ class Program { static SemaphoreSlim _semaphore = new SemaphoreSlim(4); static void AccessDatabase...翻译 2019-03-08 14:52:47 · 280 阅读 · 0 评论 -
关于C#中串口通讯数据丢失问题的优化
看别人的,通俗易懂,就不加赘述了!转载 2019-03-11 17:20:29 · 2074 阅读 · 0 评论 -
使用Monitor类锁定资源
class Program{ static void LockTooMuch(object lock1, object lock2) { lock(lock1) { Thread.Sleep(1000); lock(lock2); } } static void M...转载 2019-05-08 18:05:34 · 457 阅读 · 0 评论 -
Barrier类的使用,可作为多线程间的信号量
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Threading;namespace BarrierDemo{ class Program { st...原创 2019-06-28 16:59:49 · 388 阅读 · 0 评论