当前位置: 技术问答>linux和unix
main主线程先结束,它所创建的子线程会被取消吗
来源: 互联网 发布时间:2015-11-16
本文导语: #include #include #include void task1(int *); int g1=0; int main(int argc, char**argv) { pthread_t thread1; int ret; ret=pthread_create(&thread1, NULL, (void *)task1, (void *)&g1); if(ret) printf("error create task1n"); pthread_cancel(thread1); // pthread_jo...
#include
#include
#include
void task1(int *);
int g1=0;
int main(int argc, char**argv)
{
pthread_t thread1;
int ret;
ret=pthread_create(&thread1, NULL, (void *)task1, (void *)&g1);
if(ret)
printf("error create task1n");
pthread_cancel(thread1);
// pthread_join(thread1, NULL);
// sleep(8);
return 0;
}
void task1(int* counter)
{
while(*counter
#include
#include
void task1(int *);
int g1=0;
int main(int argc, char**argv)
{
pthread_t thread1;
int ret;
ret=pthread_create(&thread1, NULL, (void *)task1, (void *)&g1);
if(ret)
printf("error create task1n");
pthread_cancel(thread1);
// pthread_join(thread1, NULL);
// sleep(8);
return 0;
}
void task1(int* counter)
{
while(*counter