본문 바로가기
C#/책 예제

C# Thread 상태 변화

by HyunS_ 2019. 6. 8.
using System;
using System.Threading;

namespace ThreadNTask
{
    class Program
    {
        static void Main(string[] args)
        {
            PrintThreadState(ThreadState.Running);

            PrintThreadState(ThreadState.StopRequested);

            PrintThreadState(ThreadState.SuspendRequested);

            PrintThreadState(ThreadState.Background);

            PrintThreadState(ThreadState.Unstarted);

            PrintThreadState(ThreadState.Stopped);

            PrintThreadState(ThreadState.WaitSleepJoin);

            PrintThreadState(ThreadState.Suspended);

            PrintThreadState(ThreadState.AbortRequested);

            PrintThreadState(ThreadState.Aborted);

            PrintThreadState(ThreadState.Aborted | ThreadState.Stopped);
        }

        private static void PrintThreadState(ThreadState threadState)
        {
            Console.WriteLine("{0, -16} : {1}", threadState, (int)threadState);
        }
    }
}
728x90

'C# > 책 예제' 카테고리의 다른 글

C# Thread Monitor 키워드를 이용한 동기화  (0) 2019.06.08
C# Thread lock 키워드를 이용한 동기화  (0) 2019.06.08
C# Thread 인터럽트로 종료하기.  (0) 2019.06.08
C# Thread 임의 종료  (0) 2019.06.08
C# / Thread 시작  (0) 2019.06.08

댓글