Skip to content

Instantly share code, notes, and snippets.

@aleks
Created July 9, 2012 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleks/a0e2dde550adf1777ded to your computer and use it in GitHub Desktop.
Save aleks/a0e2dde550adf1777ded to your computer and use it in GitHub Desktop.
require 'thread'
class Crap
def takes_time
sleep 5
puts "Hello!!!"
end
end
QUEUE = Queue.new
Thread.new {
while work = QUEUE.pop
work.run
end
}
puts "hello world! 1"
puts "hello world! 2"
puts "hello world! 3"
puts "hello world! 4"
puts "hello world! 5"
QUEUE << Crap.new.takes_time
puts "hello world! 6"
puts "hello world! 7"
puts "hello world! 8"
puts "hello world! 9"
puts "hello world! 10"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment