waiting in a seperate thread