Replaced sleep() with wait() and notify() for faster responsiveness in stopping the data collection thread