public ThreadPool(int maxThreadCount, ThreadPoolAction <T> action) { _threadQueue = new List <MyThread>(); _dataPool = new DataPool <T>(); _lockObj = new object(); _stop = false; _action = action; _threadManger = new ManualResetEvent(false); for (int i = 0; i < maxThreadCount; i++) { MyThread item = new MyThread(i); item.Name = "download thread: " + i; if (_highPriorityThread == null) { _highPriorityThread = item; _highPriorityThread.Start(new ThreadStart(HighPriorityThreadFunc)); } else { item.Start(new ThreadStart(ThreadFunc)); } _threadQueue.Add(item); } UpdateLog.WARN_LOG("Init ThreadPool"); }
public HttpThreadPool(int maxThreadCount, ThreadPoolAction <T> action) { _action = action; _count = maxThreadCount; _stop = false; _waitWhileWorking = false; _threadQueue = new List <Thread>(); _taskList = new Queue <T>(); for (int i = 0; i < _count; i++) { Thread thread = new Thread(threadFunc); thread.Name = "download thread: " + i; thread.Start(); _threadQueue.Add(thread); } }
public ThreadMapDataPool(int maxThreadCount, ThreadPoolAction <MapFileData> action) : base(maxThreadCount, action) { }