/**************************************************************** **** **** This file belongs with the course **** Introduction to Scientific Programming in C++/Fortran2003 **** copyright 2016=2020 Victor Eijkhout eijkhout@tacc.utexas.edu **** **** block.cxx : illustration of blocking behavior of threads **** ****************************************************************/ #include using std::cout; #include #include #include #include int main() { using myclock = std::chrono::steady_clock ; //codesnippet threadracevar auto start_time = myclock::now(); auto deadline = myclock::now() + std::chrono::seconds(1); int counter{0}; auto add_thread = std::thread( [&counter,deadline]() { while (myclock::now()(duration); cout << "Runtime: " << 1.e-6 * microsec_duration.count() << " sec" << '\n'; return 0; }