static void RunThreads() { var sample = new ThreadSample(); var threadOne = new Thread(sample.CountNumbers); threadOne.Name = "ThreadOne"; var threadTwo = new Thread(sample.CountNumbers); threadTwo.Name = "ThreadTwo"; threadOne.Priority = ThreadPriority.Highest; threadTwo.Priority = ThreadPriority.Lowest; threadOne.Start(); threadTwo.Start(); Thread.Sleep(TimeSpan.FromSeconds(2)); sample.Stop(); }
static void RunThreads() { var sample = new ThreadSample(); var threadOne = new Thread(sample.CountNumbers); threadOne.Name = "ThreadOne"; var threadTwo = new Thread(sample.CountNumbers); threadTwo.Name = "ThreadTwo"; threadOne.Priority = ThreadPriority.Highest; threadTwo.Priority = ThreadPriority.Lowest; threadOne.Start(); threadTwo.Start(); Thread.Sleep(TimeSpan.FromSeconds(2)); sample.Stop(); }
/// <summary> /// 运行线程 /// </summary> static void RunThreads() { var sample = new ThreadSample(); var t1 = new Thread(sample.CountNumbers); t1.Name = "Thread One"; var t2 = new Thread(sample.CountNumbers); t2.Name = "Thread Two"; t1.Priority = ThreadPriority.Highest;//设置线程的优先级 t2.Priority = ThreadPriority.Lowest; t1.Start(); t2.Start(); Thread.Sleep(TimeSpan.FromSeconds(2)); sample.Stop(); }
public static void ThreadRun() { ThreadSample sample = new ThreadSample(); Thread t1 = new Thread(sample.CountNumber); Thread t2 = new Thread(sample.CountNumber); t1.Priority = ThreadPriority.Highest; t2.Priority = ThreadPriority.Lowest; t1.Name = "ThreadOne"; t2.Name = "ThreadTwo"; t1.Start(); t2.Start(); Sleep(TimeSpan.FromSeconds(2)); sample.Stop(); }
public static void Test() { ThreadSample sample = new ThreadSample(); Thread t1 = new Thread(sample.CountNumbers); t1.Name = "Thread First"; Thread t2 = new Thread(sample.CountNumbers); t2.Name = "Thread Second"; t1.Priority = ThreadPriority.Highest; t2.Priority = ThreadPriority.Lowest; t1.Start(); t2.Start(); Thread.Sleep(TimeSpan.FromSeconds(2)); sample.Stop(); }