C???????pthread???????
???????????? ???????[ 2016/12/29 10:46:57 ] ???????????????
??????????ж????????????ж?????????????WindowsAPI????????????GTK??????????GTK??????????????????????????и?????????????????POSIX?е?Pthread????????????????Linux??д??????????????Pthread??
????????????????Щ?????
????1.????PTHREAD??WINDOWS?????? pthreads-w32-2-4-0-release.exe???κ?????汾?????
????http://sourceware.org/pthreads-win32/ ??????????????
????2.???include??lib????У????????????????VC++6.0??????·???????????·?????棺
????a).Tools->Options?????Directory??棬?????Show directories for:?????Include files(???) ??Directories?????include??·??????Show directories for:?????Library files??
??????Directories?????lib??·????
????b).Project->Settings?????Link??棬???lib?μ?*.lib???????Object/library Modules??
??????lib???????????
????c).??lib?μ?*.dll???????????????£?????????
??????????????LINUX/UNIX/MacOSX???????????????????????????????WINDOWS?????????????????????PTHREAD??WINDOWS???????????????????С??????????http://sourceware.org/pthreads-win32/
????????????????????????
???????????
????#include<pthread.h>
????#include<iostream>
????usingnamespacestd;
????void*tprocess1(void*args){
????while(1){
????cout<<"tprocess1"<<endl;
????}
????returnNULL;
????}
????void*tprocess2(void*args){
????while(1){
????cout<<"tprocess2"<<endl;
????}
????returnNULL;
????}
????intmain(){
????pthread_tt1;
????pthread_tt2;
????pthread_create(&t1??NULL??tprocess1??NULL);
????pthread_create(&t2??NULL??tprocess2??NULL);
????pthread_join(t1??NULL);
????return0;
????}
????????????????У??????????????pthread.h?????????????????pthread??????????????????????iostream???????????????????????????????????????壬?????????????????????????д???
???????????
????void*tprocess1(void*args)
??????????????????????????pthread_create?????????????????????????????壬???????pthread_create?????????????????????????????????
??????????????????????????????壬?????????????????????????????????
????????????????main????????pthread?й???????????????
????pthread_t?????????????????????????????????????????????????????????????????????
???????????
????pthread_tt1;
????pthread_tt2;
????????????????????????????t1??t2
???????????
????pthread_create(&t1??NULL??tprocess1??NULL);
????pthread_create(&t2??NULL??tprocess2??NULL);
?????????????????pthread_create??????????????????????????
???????????
????intpthread_create(pthread_t*thread??pthread_attr_t*attr??void*(*start_routine)(void*)??void*arg);
?????????????????????????????????????????????????????????pthread_attr_t??????????????????????????????£???????б??????????????????????????????????????NULL?????????????????????????????????????????????????????????????????……???Σ???????????C????C??????????????????????е??????????????????tprocess1tprocess2д???????????????????????????????????????????????????????????????????????????????????????????????????壬????????????????????
????д???????д?????????????????????????????????????
???????????
????pthread_join(t1??NULL);
???????????????г??????????????????????????????????????????????????????????????????????ó???????????????????????……??????main??????????????????ó??????????pthread_join????????????????????????????????????????????????????????????????????????????????????????????????????????void**?????????????з????????????NULL?ɡ?
????????д?????????????????????????
???????????????Linux:
???????????????
????g++thread.cpp-othread-lpthread
????./thread
??????????????????????
??????????????VC:
?????????????????????????????????
???????????DLL????????????·?????????????????????·?????????VC6??2005??????????????????????????????SYSTEM32??ɡ?????
???????????????????
?????????У????????????????????????????????
?????????о??????????????????д????????????????????д???????????????????????????????????????????????????????????????????????????????????????????
??????
???·???
??????????????????
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