본문 바로가기
300x250

프로그래밍401

C# Thread Monitor.Wait 그리고 Monitor.Pulse 사용하기 using System; using System.Threading; namespace ThreadNTask { class Program { static void Main(string[] args) { Counter counter = new Counter(); Thread increaseThread = new Thread(new ThreadStart(counter.Increase)); Thread decreaseThread = new Thread(new ThreadStart(counter.Decrease)); increaseThread.Start(); decreaseThread.Start(); increaseThread.Join(); decreaseThread.Join(); Console.WriteLine.. 2019. 6. 8.
C# Thread Monitor 키워드를 이용한 동기화 using System; using System.Threading; namespace ThreadNTask { class Program { static void Main(string[] args) { Counter counter = new Counter(); Thread increaseThread = new Thread(new ThreadStart(counter.Increase)); Thread decreaseThread = new Thread(new ThreadStart(counter.Decrease)); increaseThread.Start(); decreaseThread.Start(); increaseThread.Join(); decreaseThread.Join(); Console.WriteLine.. 2019. 6. 8.
C# Thread lock 키워드를 이용한 동기화 using System; using System.Threading; namespace ThreadNTask { class Program { static void Main(string[] args) { Counter counter = new Counter(); Thread increaseThread = new Thread(new ThreadStart(counter.Increase)); Thread decreaseThread = new Thread(new ThreadStart(counter.Decrease)); increaseThread.Start(); decreaseThread.Start(); increaseThread.Join(); decreaseThread.Join(); Console.WriteLine.. 2019. 6. 8.
C# Thread 인터럽트로 종료하기. using System; using System.Threading; namespace ThreadNTask { class Program { static void Main(string[] args) { SlideTask slideTask = new SlideTask(100); Thread thread = new Thread(new ThreadStart(slideTask.KeepAlive)); thread.IsBackground = true; Console.WriteLine("스레드 시작"); thread.Start(); Thread.Sleep(100); Console.WriteLine("스레드 종료"); thread.Interrupt(); Console.WriteLine("스레드가 멈출때까지 대기"); t.. 2019. 6. 8.
300x250