threads: move circular wait check into Threads::is_waiting_on