/*ide
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>線程
#define NUM_THREADS 8code
void PrintHello(void args)
{
int thread_arg;
sleep(1);
thread_arg=(int)args;
printf("Hello from thread %d\n",thread_arg);
return NULL;
}
int main(int argc, char *argv[])
{
int rc,t;
pthread_t thread[NUM_THREADS];it
for(t=0;t<NUM_THREADS;t++) { printf("Creating thread %d\n",t); rc=pthread_create(&thread[t],NULL,PrintHello,(void *)t); if(rc) { printf("ERROR;return code is %d\n",rc); return EXIT_FAILURE; } } for(t=0;t<NUM_THREADS;t++) { pthread_join(thread[t],NULL); } return EXIT_SUCCESS;
}io