Skip to content

Instantly share code, notes, and snippets.

@athurg
Created December 25, 2013 16:11
Show Gist options
  • Save athurg/8124572 to your computer and use it in GitHub Desktop.
Save athurg/8124572 to your computer and use it in GitHub Desktop.
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