Better detection of thread running or not