xrpld
Loading...
Searching...
No Matches
regular.cpp
1#include <iostream>
2#include <mutex>
3#include <thread>
4#include <vector>
5
6static std::mutex gMutex;
7
8void
9worker(int id)
10{
12 std::cout << "Hello from thread " << id << "\n";
13}
14
15int
16main()
17{
18 constexpr int kNumThreads = 10;
20 threads.reserve(kNumThreads);
21 for (int i = 0; i < kNumThreads; ++i)
22 threads.emplace_back(worker, i);
23 for (auto& t : threads)
24 t.join();
25
26 std::cout << "Hello from main thread\n";
27 return 0;
28}
T emplace_back(T... args)
T lock(T... args)
T reserve(T... args)