Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
Created January 22, 2014 01:10
Show Gist options
  • Save chris-ramon/8551791 to your computer and use it in GitHub Desktop.
Save chris-ramon/8551791 to your computer and use it in GitHub Desktop.
ruby threads
#!/usr/bin/ruby
def fun1
5.times do |i|
puts "from FUNCTION ONE #{i.to_s}"
sleep(2)
end
end
def fun2
5.times do |i|
puts "from FUNCTION TWO #{i.to_s}"
sleep(1)
end
end
# t1 = Thread.new { fun1() }
# t2 = Thread.new { fun2() }
# t1.join
# t2.join
fun1
fun2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment