Skip to content

Instantly share code, notes, and snippets.

@durka
Created September 8, 2017 19:24
Show Gist options
  • Save durka/0449bbaa3ac011f125327a5e8044376a to your computer and use it in GitHub Desktop.
Save durka/0449bbaa3ac011f125327a5e8044376a to your computer and use it in GitHub Desktop.
//! ```cargo
//! [dependencies]
//! indicatif = "0.7.0"
//! ```
extern crate indicatif;
use indicatif::{ProgressBar, MultiProgress};
use std::sync::Arc;
use std::thread;
fn main() {
let bars = Arc::new(MultiProgress::new());
let bars1 = bars.clone();
let t1 = thread::spawn(move || {
let bar = bars1.add(ProgressBar::new(100));
for _ in 0..100 {
thread::sleep_ms(100);
bar.inc(1);
}
bar.finish();
});
let bars2 = bars.clone();
let t2 = thread::spawn(move || {
let bar = bars2.add(ProgressBar::new(100));
for _ in 0..100 {
thread::sleep_ms(100);
bar.inc(1);
}
bar.finish();
});
t1.join().unwrap();
t2.join().unwrap();
bars.join().unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment