Skip to content

Instantly share code, notes, and snippets.

@releu
Created May 23, 2013 06:28
Show Gist options
  • Save releu/5633095 to your computer and use it in GitHub Desktop.
Save releu/5633095 to your computer and use it in GitHub Desktop.
queue = []
gargling = Thread.new do
loop do
queue << "It's time to gargle"
sleep 60 * 60
end
end
pills = Thread.new do
loop do
queue << "It's time to take pills"
sleep 60 * 60 * 3
end
end
alarm = Thread.new do
loop do
if msg = queue.shift
system %{ say "#{msg}" }
end
sleep 1
end
end
[alarm, gargling, pills].each &:join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment