relates to threads and parallel programming
i saw a question on thread which was answered by someone .i tried the code answered by him and wrote it. i tried
#include <iostream>
#include <thread>
using namespace std;
void printx()
{
cout << "Hello world!!!!"<< endl;
cout << "Hello world!!!!"<< endl;
cout << "Hello world!!!!"<< endl;
cout << "Hello world!!!!"<< endl;
}
int main(){
cout << "Hello world!!!!"<< endl;
thread t1(printx);
//t1.join();
t1.detach();
cout << "Hello world!!!!"<< endl;
t1.join();
return 0;
}
and i received output as
Hello world!!!!
that was printed only once i don't understand shouldn't it be more number of times
Aucun commentaire:
Enregistrer un commentaire