I'm looking for solution how to break infinite loop, when the thread will be finished. code is quite complicated, so i show u only the main part. Look below
for(;;){ if(stan==false)
pthread_create(&counter, NULL, count_me, NULL);
//to create thread only once in loop
stan=true;
move=getchar();
//(...) action.... doesn't matter
}
As you see, main are waiting for user move in getchar() func. I want to break this loop, after 10 sec from create a thread.
thread def below
void *count_me(void *threadid)
{
sleep(10);
pthread_exit(NULL);
}
thx for your help