Hi All,
Am implementing the threadpool concept and have doutbt in threads being created.
Boolean bdone= ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadExecution));
I've read that when the following line is being executed, 25 threads will be created. But i want only 5 threads to run at the same time and more than 5 requests want it to be queued and the same 5 threads should be reused. In order to do this i tried to use semaphores like below.
private void ThreadExecution(Object test)
{
Semaphore maxThreads = new Semaphore(5,5);
while (maxThreads.WaitOne())
{
MY CODE
maxThreads.Release();
}
}
Initially i gave (1,1) in semaphores and only one thread was created and it did only one task, and (5,5) created one thread and it used ...
Go to the complete details ...