??????????????
????????
????#include <pthread.h>
????????????
????int pthread_create(pthread_t *thread?? const pthread_attr_t *attr?? void *(*start_routine) (void *)?? void *arg);
?????????????е???pthread_create?????????μ????????????pthread_create????????????У?start_routine??′???????????????start_routine??????????????????????pthread_create??arg???????????????ò??????????void* ??????????????????????????????壬start_routine?????????????void????????????????????????????壬start_routine????????????????????????????????pthread_join???start_routine????????
???????????
?????????????????????????????
????????????????????????????????????????????????????
??????????????????????к??????????????ú???????????????arg??????????start_rtn??????????????????????????????Щ?????????????У?????????????????arg?????????
??????????????????к??????????
?????????
?????????????????????0????????????????????????????*thread?е???????δ??????
???????????????????

 

#include <stdio.h>
#include <pthread.h>
void printThread(const char *s)
{
pid_t pid;
pthread_t tid;
pid = getpid();
tid = pthread_self();
printf("%s pid %u tid %u (0x%x) "?? s?? (unsigned int) pid?? (unsigned int) tid?? (unsigned int) tid);
}
void* run(void* arg)
{
printThread("new thread: ");
return NULL;
}
int main(void)
{
pthread_t pt;
int err = pthread_create(&pt?? NULL?? run?? NULL);
if (err != 0)
printf("can't create thread: %s "?? strerror(err));
printThread("main thread:");
pthread_join(pt?? NULL);
return 0;
}