Acaba su 2 kod arasında ne fark var.
1. Kod
/////////////////////////////////////////////////////
#include
#include
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
int main()
{
std::thread first (foo); // spawn new thread that calls foo()
std::thread second (bar,0); // spawn new thread that calls bar(0)
std::cout << "main, foo and bar now execute concurrently...\n";
// synchronize threads:
first.join(); // pauses until first finishes
second.join(); // pauses until second finishes
std::cout << "foo and bar completed.\n";
return 0;
}
2. Kod
//////////////////////////////////////////
#include
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
int main()
{
std::cout << "main, foo and bar now execute concurrently...\n";
foo();
bar(0);
std::cout << "foo and bar completed.\n";
return 0;
}////////