Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <thread>
- using namespace std;
- void f(thread::id &t_id){
- t_id=this_thread::get_id();
- }
- int main()
- {
- int n;
- cout<<"Unesi n: "<<endl;
- cin>>n;
- vector<thread::id> a(n);
- thread t[n];
- for(int i=0; i<n; ++i){
- t[i]=thread(f,ref(a[i]));
- }
- for(int i=0; i<n; ++i) {
- t[i].join();
- }
- for(int i=0; i<n; ++i)
- cout<<a[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement