1 #include <chrono> 2 #include <thread> 3 #include <vector> 4 thread_function(int my_value)5void thread_function(int my_value) { 6 int counter = 0; 7 while (counter < 20) { 8 counter++; // Break here in thread body. 9 std::this_thread::sleep_for(std::chrono::microseconds(10)); 10 } 11 } 12 main()13int main() { 14 std::vector<std::thread> threads; 15 16 for (int i = 0; i < 10; i++) 17 threads.push_back(std::thread(thread_function, threads.size() + 1)); 18 19 for (std::thread &t : threads) 20 t.join(); 21 22 return 0; 23 } 24