Created
September 8, 2017 19:24
-
-
Save durka/0449bbaa3ac011f125327a5e8044376a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //! ```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