Forum Discussion
How to Create a empty pool using C#?
Steps to Create Thread Pooling in C#.NET
static void ProcessWithThreadMethod()
{
for (int i = 0; i <= 10; i++)
{
Thread obj = new Thread(Process);
obj.Start();
}
}
static void ProcessWithThreadPoolMethod()
{
for (int i = 0; i <= 10; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Process));
}
}
using System;
using System.Threading;
using System.Diagnostics;
namespace ThreadPooling
{
class Program
{
static void Main(string[] args)
{
Stopwatch mywatch = new Stopwatch();
Console.WriteLine("Thread Pool Execution");
mywatch.Start();
ProcessWithThreadPoolMethod();
mywatch.Stop();
Console.WriteLine("Time consumed by ProcessWithThreadPoolMethod is : " + mywatch.ElapsedTicks.ToString());
mywatch.Reset();
Console.WriteLine("Thread Execution");
mywatch.Start();
ProcessWithThreadMethod();
mywatch.Stop();
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com