using System;
using System.Threading;
class ThreadPoolDemo {
publicvoid LongTask1(object obj) {
for (int i = 0; i <= 999; i++) {
Console.WriteLine("Long Task 1 is being executed");
}
}
publicvoid LongTask2(object obj) {
for (int i = 0; i <= 999; i++) {
Console.WriteLine("Long Task 2 is being executed");
}
}
staticvoid Main() {
ThreadPoolDemo tpd = new ThreadPoolDemo();
for (int i = 0; i < 50; i++) {
ThreadPool.QueueUserWorkItem(new WaitCallback(tpd.LongTask1));
ThreadPool.QueueUserWorkItem(new WaitCallback(tpd.LongTask2));
}
Console.Read();
}
}