resolve thread deadlock