#include <iostream>
#include <boost/thread.hpp>
usingnamespace std;
usingnamespace boost;
void thread1()
{
cout<<"Hello World for the first time\nin the first(1.) thread!"<<endl;
this_thread::sleep(posix_time::milliseconds(1));
cout<<"Hello World for the second time\nin the first(1.) thread!"<<endl;
}
void thread2()
{
cout<<"Hello World for the first time\nin the second(1.) thread!"<<endl;
this_thread::sleep(posix_time::milliseconds(1));
cout<<"Hello World for the second time\nin the second(1.) thread!"<<endl;
}
int main()
{
thread a(thread1), b(thread2);
cout<<cout<<"Hello World for the first time\nn the main() thread!"<<endl;
this_thread::sleep(posix_time::milliseconds(1));
cout<<cout<<"Hello World for the second time\nin the main() thread!"<<endl;
a.join();
b.join();
}
0x47bfc4Hello World for the first time
n the main() thread!
0x47bfc4Hello World for the second time
in the main() thread!
Hello World for the first time
in the first(1.) thread!
Hello World for the second time
in the first(1.) thread!
Hello World for the first time
in the second(1.) thread!
Hello World for the second time
in the second(1.) thread!
^^ Agree with Xerzi and Viliml! Your parameters (boolean statement) says to stop at a crazy high number so it's going to print that until you hit those values in the boolean statement.
I dont know what the original code was, but the current code and output look fine to me although I dont think the order is guaranteed. What output did you expect?