Added multi-threaded progress bar example

This commit is contained in:
Pranav Srinivas KumaR
2019-12-03 20:14:05 -06:00
parent 6e7926bd96
commit e5bb15e0ba
2 changed files with 28 additions and 13 deletions

View File

@@ -18,10 +18,24 @@ int main() {
//
//
for (size_t i = 0; i < 101; i += 5) {
bar.set_progress(i);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
std::thread first_job(
[&bar]() {
for (size_t i = 0; i <= 50; ++i) {
bar.tick();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
});
std::thread second_job(
[&bar]() {
for (size_t i = 0; i <= 50; ++i) {
bar.tick();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
});
first_job.join();
second_job.join();
return 0;
}