Skip to content

Instantly share code, notes, and snippets.

@pramatias
Created April 15, 2011 11:45
Show Gist options
  • Save pramatias/921577 to your computer and use it in GitHub Desktop.
Save pramatias/921577 to your computer and use it in GitHub Desktop.
a = ""
func1 = Proc.new do
i = 0
while i <= 100
puts "func1 "
sleep(0.001)
a.concat "aaaa"
i = i + 1
end
end
func2 = Proc.new do
i = 0
while i <= 100
puts "func2 "
sleep(0.001)
a.concat "bbbb"
i = i + 1
end
end
puts "Start at: #{Time.now}"
t1 = Thread.new{func1.call}
t2 = Thread.new{func2.call}
t1.join
t2.join
puts "a is #{a}"
puts "End at: #{Time.now}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment