/
rgd045
/
cpp
Обзор
Документация
Войти
/
rgd045
/
cpp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
concurrency/thread/main.cpp
33 строки
626 B
alzoi
Create main.cpp
25 окт 2022, 12:49
Не верифицирован
25 окт 2022, 12:49
f3adb3f
Код
Авторство
О чём код?
#include "./inc/all_hed.hpp" /* #include <iostream> #include <thread> #include <chrono> */ void foo() { // simulate expensive operation std::this_thread::sleep_for(std::chrono::seconds(1)); } void bar() { // simulate expensive operation1. std::this_thread::sleep_for(std::chrono::seconds(1)); } int main() { std::cout << "starting first helper...\n"; std::thread helper1(foo); std::cout << "starting second helper...\n"; std::thread helper2(bar); std::cout << "waiting for helpers to finish..." << std::endl; helper1.join(); helper2.join(); std::cout << "done!\n"; }