This is simple implementation of latch. When you need to skip some calculation for sumultaneous threads running at the same time and peforming the same calculation (for instance calculate the same Fibonacci number 13) you may rely on this code to make the calculation be performed in ONLY single thread.
As soon as calculation is ready, all waiting threads will be provided with same result.
You may significantly decrease CPU load by using this latch.