Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <thread>
  4.  
  5. using namespace std;
  6.  
  7. // print vector to console
  8. void print_v(const vector<double>& x) {
  9.     cout << "x: ";
  10.     for (unsigned i = 0; i < x.size()-1; ++i)
  11.         cout << x[i] << ", ";
  12.     cout << x[x.size() - 1] << endl;
  13. }
  14.  
  15. void thread_me() {
  16.     vector<double> v;
  17.     v.push_back(343.0);
  18.     v.assign(10, v[0]);
  19.     print_v(v);
  20. }
  21.  
  22. // go go go
  23. int main() {
  24.     for (unsigned i = 0; i < 10; ++i) {
  25.         std::thread thread(thread_me);
  26.         thread.join();
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement