다음과 같은 예제 프로그램을 작성하였습니다.
간단하게 헬로월드를 출력하는 프로그램입니다..
[code:1]
#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 5
void *printHello(void *threadid)
{
printf("\n%d: Hello, World!\n", threadid);
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc, t;
for(t=0; t<NUM_THREADS; ++t)
{
printf("Creating thread %d\n", t);