http://stackoverflow.com/questions/12382898/how-do-i-check-the-state-of-a-thread