Skip to content

Commit

Permalink
Change to simulate contention
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Sep 8, 2017
1 parent c199430 commit 98a7803
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/multi/main_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")

bar1 = bars.register "foo [:bar] :percent", total: 20
bar2 = bars.register "bar [:bar] :percent", total: 30
bar3 = bars.register "baz [:bar] :percent", total: 10
bar1 = bars.register "foo [:bar] :percent", total: 15
bar2 = bars.register "bar [:bar] :percent", total: 15
bar3 = bars.register "baz [:bar] :percent", total: 45

bars.start

th1 = Thread.new { 20.times { sleep(0.2); bar1.advance } }
th2 = Thread.new { 30.times { sleep(0.1); bar2.advance } }
th3 = Thread.new { 10.times { sleep(0.3); bar3.advance } }
th1 = Thread.new { 15.times { sleep(0.1); bar1.advance } }
th2 = Thread.new { 15.times { sleep(0.1); bar2.advance } }
th3 = Thread.new { 45.times { sleep(0.1); bar3.advance } }

[th1, th2, th3].each(&:join)

0 comments on commit 98a7803

Please sign in to comment.