sleep and resume of thread