Pogledajte određenu poruku
Staro 29. 08. 2008.   #1
orangem
član
Na probnom radu
 
Datum učlanjenja: 17.11.2007
Poruke: 36
Hvala: 4
0 "Hvala" u 0 poruka
orangem is on a distinguished road
Default 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.
orangem je offline   Odgovorite uz citat