public WorkerQueuePrivate(ThreadProc thread_proc, int num_worker_threads, object[] tasks) { thread_list = new List <ThreadObj>(); int i; this.thread_proc = thread_proc; this.num_worker_threads = num_worker_threads; foreach (object task in tasks) { taskQueue.Enqueue(task); } raised_exception = null; for (i = 0; i < num_worker_threads; i++) { ThreadObj t = new ThreadObj(worker_thread); thread_list.Add(t); } foreach (ThreadObj t in thread_list) { t.WaitForEnd(); } if (raised_exception != null) { throw raised_exception; } }
public WorkerQueuePrivate(ThreadProc thread_proc, int num_worker_threads, object[] tasks) { thread_list = new List<ThreadObj>(); int i; this.thread_proc = thread_proc; this.num_worker_threads = num_worker_threads; foreach (object task in tasks) { taskQueue.Enqueue(task); } raised_exception = null; for (i = 0; i < num_worker_threads; i++) { ThreadObj t = new ThreadObj(worker_thread); thread_list.Add(t); } foreach (ThreadObj t in thread_list) { t.WaitForEnd(); } if (raised_exception != null) { throw raised_exception; } }
public static void SleepThread(int millisec) { ThreadObj.Sleep(millisec); }