pthread and sleep merged