Added a waiting thread to the onResume method