????Linux?μ?????
???????????? ???????[ 2014/2/24 10:44:28 ] ??????????????? ???? ??????
??????????????
????????
????#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;
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11