Pokusavam da uradim najednostavniju multithreaded aplikaciju:
Kod:
#include <iostream>
#include <thread>
#include <chrono>
using namespace std;
void f()
{
while(1)
{
cout << "From SIDE thread." << endl;
this_thread::sleep_for(chrono::seconds(2));
}
}
int main(int argc, _TCHAR* argv[])
{
thread t1(f);
t1.join();
while(1)
{
cout << "From MAIN thread." << endl;
this_thread::sleep_for(chrono::seconds(2));
}
return 0;
}
Ali izgleda da se scope prebaci u tu f-ju i ne vrati se u main, i dalje izvrsavajuci tu f-ju, kao bi ja hteo.
Tj. hocu da output bude, malo iz jedne f-je malo iz main.
Sta radim pogresno?