// If we are not thinking, wait for a condition to be signaled
// instead of wasting CPU time polling for work.
// If we are not thinking, wait for a condition to be signaled
// instead of wasting CPU time polling for work.
// If this thread has been assigned work, launch a search
if (threads[threadID].state == THREAD_WORKISWAITING)
{
// If this thread has been assigned work, launch a search
if (threads[threadID].state == THREAD_WORKISWAITING)
{
threads[0].state = THREAD_SEARCHING;
for (i = 1; i < MAX_THREADS; i++)
threads[i].state = THREAD_AVAILABLE;
threads[0].state = THREAD_SEARCHING;
for (i = 1; i < MAX_THREADS; i++)
threads[i].state = THREAD_AVAILABLE;