Posted By

medikgt on 06/25/09


Tagged

boost Threads


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

khouser


Boost Threads


 / Published in: C++
 

  1. #include <boost/thread/thread.hpp>
  2. #include <iostream>
  3. #include "windows.h"
  4.  
  5. using namespace std;
  6. using namespace boost;
  7.  
  8. void even()
  9. {
  10. for(int i=0; i<=100; i+=2)
  11. {
  12. cout << i << endl;
  13. Sleep(1000);
  14. }
  15. }
  16.  
  17. void odd()
  18. {
  19. for(int i=1; i<=99; i+=2)
  20. {
  21. cout << i << endl;
  22. Sleep(1000);
  23. }
  24. }
  25.  
  26. int main(int argc, char* argv[])
  27. {
  28. thread thrd1(&even);
  29. thread thrd2(&odd);
  30.  
  31. thrd1.join();
  32. thrd2.join();
  33.  
  34. return 0;
  35. }

Report this snippet  

You need to login to post a comment.