Created
January 17, 2015 19:54
-
-
Save semaperepelitsa/8b81f77f6ad894099e2d 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
require "thread" | |
mutex = Mutex.new | |
i = 0 | |
while true | |
i += 1 | |
Thread.new(i) do |n| | |
mutex.synchronize do | |
puts "#{n}. started request" | |
Thread.new(n) do |n| | |
puts "#{n}. started background" | |
sleep 10 | |
puts "#{n}. finished background" | |
end | |
sleep 1 | |
puts "#{n}. finished request" | |
end | |
end | |
sleep 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment