Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created May 13, 2013 09:35
Show Gist options
  • Save andrijac/5567190 to your computer and use it in GitHub Desktop.
Save andrijac/5567190 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
namespace ConsoleApplication11
{
internal class Program
{
private static void Main(string[] args)
{
for (int i = 0; i < 50; i++)
{
ThreadPool.QueueUserWorkItem(Handler, i);
}
Console.ReadLine();
}
private static void Handler(object state)
{
Execute((int)state);
}
private static void Execute(int i)
{
int index = i;
Thread.Sleep((new Random(100)).Next(1000));
Console.WriteLine(index.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment