コード例 #1
0
 public void Sort(byte[] values)
 {
     foreach (var item in values)
     {
         ThreadPoolSleepSorter sleeper = new ThreadPoolSleepSorter(item, _writter);
         coll.Add(sleeper);
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tymicruz/4dos2
        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!");
        }