-
-
Save hanachin/c0404c9cd5b8a54a210f3763f48b91ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f | |
sleep 1 | |
end | |
BEGIN { | |
using Module.new { | |
refine(Kernel) do | |
def sleep *; end | |
end | |
} | |
} | |
100.times { f } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f | |
sleep 1 | |
end | |
100.times.map { Thread.new { f } }.each(&:join) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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