as expected with some thread libraries. For an adhoc workaround for this problem, insert usleep() in the loop to force context switch. The original code should be rewritten using a conditional variable.