Created
December 25, 2013 16:11
-
-
Save athurg/8124572 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
threads = [] | |
status=[] | |
30.times {|i| status[i]=false} | |
chars=['-', "\\", '|', '/', '-', "\\", '|', '/'] | |
puts '' | |
inprocess=true | |
threads << Thread.new do | |
while inprocess | |
chars.each do |char| | |
printf "\r" | |
30.times do |i| | |
printf status[i]==true ? '.' : char | |
inprocess ||= status[i] | |
end | |
sleep 0.2 | |
end | |
end | |
end | |
threads << Thread.new do | |
while inprocess | |
status[rand(30)]=true | |
sleep 1 | |
end | |
end | |
threads.each {|t| t.join} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment