Created
May 23, 2013 06:28
-
-
Save releu/5633095 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
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