// thread01.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define N 5
void *worker_thread(void *arg)
{
printf("This is worker_thread #%ld
", (long)arg);
pthread_exit(NULL);
}
int main()
{
pthread_t my_thread[N];
long id;
for(id = 1; id <= N; id++) {
int ret = pthread_create(&my;_thread[id], NULL, &worker;_thread, (void*)id);
if(ret != 0) {
printf("Error: pthread_create() failed
");
exit(EXIT_FAILURE);
}
}
pthread_exit(NULL);
}