Lucene.Net.Index.TestDocumentsWriterStallControl.AwaitState C# (CSharp) Method

AwaitState() public static method

Waits for all incoming threads to be in wait() methods.
public static AwaitState ( ThreadState state ) : void
state ThreadState
return void
        public static void AwaitState(ThreadState state, params ThreadClass[] threads)
        {
            while (true)
            {
                bool done = true;
                foreach (ThreadClass thread in threads)
                {
                    if (thread.State != state)
                    {
                        done = false;
                        break;
                    }
                }
                if (done)
                {
                    return;
                }
                if (Random().NextBoolean())
                {
                    Thread.@Yield();
                }
                else
                {
                    Thread.Sleep(1);
                }
            }
        }