/* Criação de threads POSIX em UNIX. Compilar com gcc -Wall thread-create.c -o thread-create -lpthread Carlos Maziero, DINF/UFPR 2020 */ #include #include #include #include #define NUM_THREADS 16 void *threadBody (void *id) { long tid = (long) id ; // ID da thread printf ("t%02ld: Olá!\n", tid) ; sleep (3) ; printf ("t%02ld: Tchau!\n", tid) ; pthread_exit (NULL) ; } int main (int argc, char *argv[]) { pthread_t thread [NUM_THREADS] ; long i, status ; for (i=0; i