public void ReturnThread(IJvmThread thread) { Debug.Assert(thread != null); if (thread.IsAttached) throw new InvalidOperationException("Invalid thread state. Cannot return attached thread."); thread.Dispose(); }
public void ReturnThread(IJvmThread thread) { Debug.Assert(thread != null); if (thread.IsAttached) throw new InvalidOperationException("Invalid thread state. Cannot return attached thread to pool."); if (!(thread is PooledThread)) throw new InvalidOperationException("Invalid thread type."); try { _lock.Wait(); if (!_activeThreads.Contains(thread)) throw new InvalidOperationException("Pool does not contain thread."); _activeThreads.Remove(thread); if (_pendingThreads.Count < _minPoolSize) _pendingThreads.AddLast(thread); else thread.Dispose(); } finally { _lock.Release(); } }