Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- using namespace std;
- void proc(int* n) {
- static const int INC_COUNT = 10000000;
- for (int i = 0; i < INC_COUNT; i++)
- (*n)++;
- }
- int main() {
- int n = 0;
- static const int THREAD_COUNT = 2;
- thread* t[THREAD_COUNT];
- for (int i = 0; i < THREAD_COUNT; i++)
- t[i] = new thread(proc, &n);
- for (int i = 0; i < THREAD_COUNT; i++) {
- t[i]->join();
- delete t[i];
- }
- cout << n << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement