private bool AllThreadsIdle() { lock (this) { for (int i = 0; i < threadStates.Length; i++) if (!threadStates[i].isIdle) return false; return true; } }