POSIX thread-ovi
Da li je moguce provjeriti stanje thread-a ( da li je aktivan ili nije ), pomocu thread handler-a?
Npr.
#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 5
void *thr_id(void *threadid)
{
int tid;
tid = (int)threadid;
printf("Thread #%d!\n", tid);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc, t;
for(t=0; t<NUM_THREADS; t++)
{
pthread_create(&threads[t], NULL, thr_id, (void *)t);
}
/*Meni bi trebalo ovako nesto*/
for(t=0; t<NUM_THREADS; t++)
{
if(test_handler(threads[t]) == ACTIVE)
{
URADI NESTO
}
}
/*Kraj primjera*/
pthread_exit(NULL);
}
pthread_join - ne moze da mi pomogne jer moram cekati cijeli thread da se zavrsi, da bih nastavio iteraciju kroz petlju.
Poz.
|