I'm testing the new std::thread with this program
#include <iostream>
#include <thread>
#include <cstdlib>
using namespace std;
int threads=0;
void countToInfinity(){
int thread = threads++;
for(int i=0; i<100; i++){
cout << thread << ": " << i << endl;
std::this_thread::sleep_for(std::chrono::milliseconds(rand()%10));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
}
int main()
{
cout << "bu";
std::thread my_thread(countToInfinity);
std::thread my_thread2(countToInfinity);
my_thread.join();
my_thread2.join();
return 0;
}
int project -> project properties -> build targets -> pause when execution ends
checking this checkbox causes my program to fail with:
terminate called after throwing an instance of 'std::system_error'
what():
aborted
Process returned 134(0x86)
I've verified that the program itself works correctly by running it from the command line.
I'm using ubuntu with g++ 4.5.2 codeblocks 10.05