Skip to content

Instantly share code, notes, and snippets.

@davydovanton
Created August 16, 2015 14:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davydovanton/0762cf5b3b1b05f854d9 to your computer and use it in GitHub Desktop.
Save davydovanton/0762cf5b3b1b05f854d9 to your computer and use it in GitHub Desktop.
# Делаем новый тред, который ждет когда выполниться Thread.run
# в основном треде. После чего из основного запускаем "заснувший"
# тред и получаем дедлок
thread = Thread.new { Thread.stop }
thread.status # => 'sleep'
thread.join # => deadlock!
# что бы распутать такую штуку, достаточно просто сделать проверку на статус
thread = Thread.new { Thread.stop }
thread.run if thread.status == 'sleep'
thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment