#include #include #include #include #include void *thread_functionA(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadA ! \n"); return NULL; } void *thread_functionB(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadB ! \n"); return NULL; } void *thread_functionC(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadC ! \n"); return NULL; } void *thread_functionD(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadD ! \n"); return NULL; } void *thread_functionE(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadE ! \n"); return NULL; } void *thread_functionF(void *arg){ int i; double x=(((float)rand())/RAND_MAX)*1e6; usleep(x); printf("Sono il threadF ! \n"); return NULL; } int main(void) { srand(time(0)); pthread_t mythreadA, mythreadB, mythreadC, mythreadD, mythreadE, mythreadF; pthread_create( &mythreadA, NULL, thread_functionA, NULL); pthread_join ( mythreadA, NULL ); pthread_create( &mythreadB, NULL, thread_functionB, NULL); pthread_create( &mythreadC, NULL, thread_functionC, NULL); pthread_join ( mythreadC, NULL ); pthread_create( &mythreadD, NULL, thread_functionD, NULL); pthread_create( &mythreadE, NULL, thread_functionE, NULL); pthread_join ( mythreadB, NULL ); pthread_join ( mythreadD, NULL ); pthread_join ( mythreadE, NULL ); pthread_create( &mythreadF, NULL, thread_functionF, NULL); pthread_join ( mythreadF, NULL ); exit(0); }