Arton

condition variable version
    
I think the condition variable can avoid extra cpu occupy.
For example, if we change the max thread count to 4 or the number of our cores.
The polling in "while" will decrease the performance.
    
Finally, it is faster than polling version when MAX_THREAD_COUNT is 4,
but MUCH slower in other condition.

(The first commit is a polling version with the same logic but with polling.)