摘要:
class Program { static ManualResetEventSlim manualRestEvnetSlim = new ManualResetEventSlim(false); static void TravelThroughGates(string threadName,in 阅读全文
摘要:
class Program { private static AutoResetEvent workEvent = new AutoResetEvent(false); private static AutoResetEvent mainEvnet = new AutoResetEvent(fals 阅读全文
摘要:
class Program { static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(2); static void Main() { for(int i=0;i<=6;i++) { string threadName = "Thread" + 阅读全文
摘要:
class Program { static void Main() { const string MutexName = "CSharpThreadingCookbook"; using (var m = new Mutex(false, MutexName)) { if (!m.WaitOne( 阅读全文
摘要:
class Program { static void Main() { object lock1 = new object(); object lock2 = new object(); new Thread(() => LockTooMuch(lock1, lock2)).Start(); lo 阅读全文
摘要:
class Program { static void Main() { Console.WriteLine("Start"); var c = new Counter(); var t1 = new Thread(() => TestCounter(c)); var t2 = new Thread 阅读全文
摘要:
class Program { static void Main() { var sample = new ThreadSample(10); var threadOne = new Thread(sample.CountNumbers); threadOne.Name = "ThreadOne"; 阅读全文
摘要:
class Program { static void Main() { //没啥作用,除非你 限制一个进程,把线程都在里面跑,限制住一个cpu内核.. Thread t = new Thread(ShowMessage); t.Name = "One"; //最高等级 t.Priority = T 阅读全文
摘要:
class Program { static void Main() { Console.WriteLine("Main Thread State={0}", Thread.CurrentThread.ThreadState.ToString()); Thread t = new Thread(Sh 阅读全文
摘要:
class Program { static void Main() { Thread t = new Thread(ShowMessage); t.Start(); //阻塞主线程,让它等我完成之后,在走主线程 t.Join(); for (var i = 0; i < 10; i++) { Co 阅读全文