#include #include #include #include #define NUM_THREADS 16 void *thread(void *thread_id) { int id = *((int *) thread_id); printf("Hello from thread %d\n", id); return NULL; } int main() { pthread_t threads[NUM_THREADS]; int tabid[NUM_THREADS]; for (int i = 0; i < NUM_THREADS; i++){ tabid[i] = i+1; } for (int i = 0; i < NUM_THREADS; i++){ assert( pthread_create(&threads[i], NULL, thread, &tabid[i]) == 0); } for (int i = 0; i < NUM_THREADS; i++){ assert( pthread_join(threads[i], NULL) == 0); } return EXIT_SUCCESS; }