public void execute(Runnable runnable) { List <Thread> threadListRemove = new List <Thread>(); foreach (Thread objThread in this.threadList) { if (!objThread.IsAlive) { threadListRemove.Add(objThread); } } foreach (Thread threadToRemove in threadListRemove) { this.threadList.Remove(threadToRemove); } if (threadList.Count >= maxThreads) { return; } runnable.SetPoolManager(this); Thread th = new Thread(new ThreadStart(runnable.executeInThread)); threadList.Add(th); th.Start(); }