private bool killThreadIfNeeded() { if (poolSize < threads.Count) { lock (threads) { if (poolSize < threads.Count) { WatchableThread wt = null; foreach (var tc in threads) { if (tc.Thread == Thread.CurrentThread) { wt = tc; } } if (wt != null) { threads.Remove(wt); } return(true); } } } return(false); }
private void spawnThreads() { while (threads.Count < poolSize) { WatchableThread t = new WatchableThread(this); threads.Add(t); } }