public static void ThreadT1() { Console.WriteLine($"Thrad:{Thread.CurrentThread.ManagedThreadId}"); ThreadTest t1 = new ThreadTest(); Thread th1 = new Thread(t1.HelloWorld); th1.Start(); Thread th2 = new Thread(t1.RepeatHelloWorld); th2.Start(5); }
[MTAThread] // 멀티스레드 동작한다는것. 안써도됨 public static void Main() { ThreadTest t = new ThreadTest(); // CLR에 있는 Main Thread가 실행 //Thread는 생성자에 ThreadStart형 Delegate를 인자로 받는다. Thread first = new Thread(t.FirstWork); Thread second = new Thread(new ThreadStart(t.SecondWork)); first.Priority = ThreadPriority.Lowest; // 우선순위 약하게 second.Priority = ThreadPriority.Highest; // 우선순위 쎄게 first.Start(); second.Start(); }