// basic POSIX threads (pthread) example - Educational Use Only
// by Pegasus Epsilon <pegasus@pimpninjas.org>
//
// $ cc pthread.c -lpthread -o pthread
//
#include <pthread.h> /* pthread_* */
#include <stdio.h> /* printf() */
#include <stdlib.h> /* EXIT_SUCCESS */
void *hello (void *arg) {
printf("Hello, World! This is thread ID #%lu!\n", *(long *)arg);
pthread_exit(EXIT_SUCCESS);
}
int main (void) {
pthread_t thread;
for (long i = 0; i < 20; i++)
pthread_create(&thread, NULL, &hello, &i);
pthread_join(thread, NULL);
return 0;
}