Created
May 13, 2013 09:35
-
-
Save andrijac/5567190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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