fix thread detection when using mutex or condition