thread state detecting
unit test for thread