sleep() isn't defined to be per thread; use usleep() instead which is.