Skip to content

Instantly share code, notes, and snippets.

@hanachin
Last active July 3, 2020 05:43
Show Gist options
  • Save hanachin/c0404c9cd5b8a54a210f3763f48b91ac to your computer and use it in GitHub Desktop.
Save hanachin/c0404c9cd5b8a54a210f3763f48b91ac to your computer and use it in GitHub Desktop.
def f
sleep 1
end
BEGIN {
using Module.new {
refine(Kernel) do
def sleep *; end
end
}
}
100.times { f }
def f
sleep 1
end
100.times.map { Thread.new { f } }.each(&:join)
def f
sleep 1
end
100.times.map { fork { f } }.compact.each { Process.waitpid(_1) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment