■ ThreadPool 클래스의 GetMinThreads 정적 메소드를 사용해 최소 스레드 수를 설정하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
using System; using System.Threading; int workerThreadCount, completionPortThreadCount; ThreadPool.GetMinThreads(out workerThreadCount, out completionPortThreadCount); Console.WriteLine("BEFORE UPDATE"); Console.WriteLine("--------------------------------------------------" ); Console.WriteLine("WORKER THREAD COUNT : {0}", workerThreadCount ); Console.WriteLine("COMPLETION PORT THREAD COUNT : {0}", completionPortThreadCount); Console.WriteLine("--------------------------------------------------" ); Console.WriteLine(); ThreadPool.SetMinThreads(25, completionPortThreadCount); ThreadPool.GetMinThreads(out workerThreadCount, out completionPortThreadCount); Console.WriteLine("AFTER UPDATE"); Console.WriteLine("--------------------------------------------------" ); Console.WriteLine("WORKER THREAD COUNT : {0}", workerThreadCount ); Console.WriteLine("COMPLETION PORT THREAD COUNT : {0}", completionPortThreadCount); Console.WriteLine("--------------------------------------------------" ); |