쓰레드가 관리 쓰레드 풀에 속하는지 확인하기 위한 코드는 다음과 같다 -
예
using System;
using System.Threading;
public class Demo {
public static void Main() {
Thread thread = new Thread(new ThreadStart(demo));
thread.Start();
}
public static void demo() {
Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Thread belongs to managed thread pool? = False
예
다른 예를 살펴보겠습니다 -
using System;
using System.Threading;
public class Demo {
public static void Main() {
ThreadPool.QueueUserWorkItem(new WaitCallback(demo));
}
public static void demo(object stateInfo) {
Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Thread belongs to managed thread pool? = True