public static void DelegateTest() { ThreadStart d = new ThreadStart(Gen <T> .Target); d(); Test_thread25.Eval(Test_thread25.Xcounter == 1); Test_thread25.Xcounter = 0; }
public static void ThreadPoolTest() { ManualResetEvent evt = new ManualResetEvent(false); TimerCallback tcb = new TimerCallback(Gen <T> .Target); Timer timer = new Timer(tcb, evt, Test_thread25.delay, Test_thread25.period); evt.WaitOne(); timer.Dispose(); Test_thread25.Eval(Test_thread25.Xcounter >= Test_thread25.nThreads); Test_thread25.Xcounter = 0; }
public static void ThreadPoolTest() { Thread[] threads = new Thread[Test_thread25.nThreads]; for (int i = 0; i < Test_thread25.nThreads; i++) { threads[i] = new Thread(new ThreadStart(Gen <T> .Target)); threads[i].Start(); } for (int i = 0; i < Test_thread25.nThreads; i++) { threads[i].Join(); } Test_thread25.Eval(Test_thread25.Xcounter == Test_thread25.nThreads); Test_thread25.Xcounter = 0; }
public static void ThreadPoolTest() { ManualResetEvent[] evts = new ManualResetEvent[Test_thread25.nThreads]; WaitHandle[] hdls = new WaitHandle[Test_thread25.nThreads]; for (int i = 0; i < Test_thread25.nThreads; i++) { evts[i] = new ManualResetEvent(false); hdls[i] = (WaitHandle)evts[i]; } Gen <T> obj = new Gen <T>(); for (int i = 0; i < Test_thread25.nThreads; i++) { WaitCallback cb = new WaitCallback(Gen <T> .Target); ThreadPool.QueueUserWorkItem(cb, evts[i]); } WaitHandle.WaitAll(hdls); Test_thread25.Eval(Test_thread25.Xcounter == Test_thread25.nThreads); Test_thread25.Xcounter = 0; }