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