Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- #include <vector>
- #include <chrono>
- int main()
- {
- std::vector<std::thread> threads;
- int counter = 0;
- while (true)
- {
- try
- {
- threads.emplace_back
- (
- []
- {
- using namespace std::chrono_literals;
- std::this_thread::sleep_for(3600s) ;
- }
- );
- counter++;
- }
- catch (...)
- {
- std::cout << "thread count: " << counter << std::endl;
- break;
- }
- }
- for (auto && thread : threads)
- {
- thread.join();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement