fix deadlock checking method and implement timeout