#include <pthread.h>
#include <iostream>
using namespace std;
void* printChar(void* data)
{
int a = *reinterpret_cast<int*>(data);
while(true)
cout<<a++<<endl;
return reinterpret_cast<void*>(*reinterpret_cast<int*>(data));
}
int main(void)
{
pthread_t tid1;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
int* a = new int(0);
pthread_create(&tid1,&attr,printChar,reinterpret_cast<void*>(a));
while (true)
{
if ('q' == getchar())
{
break;
}
}
delete a;
return 0;
}