public void Sort(byte[] values) { foreach (var item in values) { ThreadPoolSleepSorter sleeper = new ThreadPoolSleepSorter(item, _writter); coll.Add(sleeper); } }
public ThreadPoolSleepSorter(TextWriter output, ushort threadCount) { allThreads = new List <Thread> { }; coll = new BlockingCollection <ThreadPoolSleepSorter>(); _writter = output; if (threadCount == 0) { threadCount = 64; } for (int i = 0; i < threadCount; i++) { ThreadPoolSleepSorter sleeper = new ThreadPoolSleepSorter(); Thread t = new Thread(sleeper.ThreadWorkFunc); t.Start(coll); allThreads.Add(t); } }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); ThreadPoolSleepSorter tpss = new ThreadPoolSleepSorter(Console.Out, 64); tpss.Sort(new byte[] { 3, 2, 4, 1, 5, 4, 1, 6 }); //tpss.Sort(new byte[] { 3, 2, 4, 1, 5 }); //tpss.Dispose(); //Thread ens = new Thread(() => e(40000)); //Thread des = new Thread(() => d(100000)); //queue.Print (); //ens.Start(); //des.Start(); //Thread.Sleep(10000); //queue.Print (); //BlockingCollection<int> cs = new BlockingCollection<int>(); // cs.Add(6); //cs.Take(); tpss.Dispose(); // Console.WriteLine("Hello World!"); }