スレッドの利用サンプル
#include <iostream>
#include <SDL.h>
using namespace hrk;
using namespace std;
namespace
{
int number_output(void* arg)
{
int* first_value = reinterpret_cast<int*>(arg);
enum { Loop_times = 10 };
int value = *first_value;
for (int i = 0; i < Loop_times; ++i) {
cout << value << endl;
++value;
delay_msec(10);
}
return value;
}
}
int main(int argc, char *argv[])
{
static_cast<void>(argc);
static_cast<void>(argv);
int first_values[2] = { 0, 100 };
Thread thread_1st(number_output, &first_values[0]);
Thread thread_2nd(number_output, &first_values[1]);
thread_1st.run();
thread_2nd.run();
cout << "1st: last_value: " << thread_1st.wait() << endl;
cout << "2nd: last_value: " << thread_2nd.wait() << endl;
return 0;
}