Linux 執行緒的建立與結束

2021-06-11 07:38:52 字數 742 閱讀 2084

#include

#include

#include

#include

using namespace std;

char message  = "init message !";

void* thread_function(void *);

int main()

res = pthread_join(tid, &thread_result);

if (res!=0)

printf("thread returned %s\n", (char*)thread_result);

printf("message is now %s\n", message); 

return 0;

}void* thread_function(void *arg)

while(count++ <=20)

else

}printf("\nwait for thread to finish......\n");

res = pthread_join(threadid, &threadresult);

if (res != 0)

return(exit_success);

}g++ thr.cpp -lpthread -o thr -ggdb && ./thr

121212121212121212121

wait for thread to finish......

vc 執行緒的建立,暫停和結束

1.執行緒的建立 1 cwinthread mainthread mainthread afxbeginthread mythread,this,thread priority normal,0,0,null 2 後台工作執行緒函式 uint mythread lpvoid pparam 3 fun...

vc 執行緒的建立 暫停和結束

1.執行緒的建立 1 cwinthread mainthread mainthread afxbeginthread mythread,this,thread priority normal,0,0,null 2 後台工作執行緒函式 uint mythread lpvoid pparam 3 fun...

vc 執行緒的建立,暫停和結束

1.執行緒的建立 1 cwinthread mainthread mainthread afxbeginthread mythread,this,thread priority normal,0,0,null 2 後台工作執行緒函式 uint mythread lpvoid pparam 3 fun...