Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <thread>
- using namespace std;
- int foo()
- {
- for (int i = 0; i < 5; i++) {
- cout << "Thread " << i << endl;
- Sleep(500);
- }
- return 0;
- }
- int foo2()
- {
- for (int i = 0; i < 5; i++) {
- cout << "Thread2 " << i << endl;
- Sleep(500);
- }
- return 0;
- }
- int main()
- {
- cout << "Pocetak" << endl;
- Sleep(500);
- thread th1(foo);
- thread th2(foo2);
- int i = 0;
- while (i++ < 10) {
- cout << "Kraj " << i << endl;
- Sleep(500);
- }
- th1.detach();
- th2.detach();
- return 0;
- }
Add Comment
Please, Sign In to add comment