1.线程的取消
NAME
pthread_cancel - send a cancellation request to a thread
SYNOPSIS
#include <pthread.h>
int pthread_cancel(pthread_t thread);
①取消有两种状态,允许和不允许
②允许取消又分为
异步cancel
推迟cancel(默认) 推迟到cancel点才被响应
cancel点: posix定义的cancel点 都是可能引发阻塞的系统调用
2.pthread_setcancelstate
设置取消方式
NAME
pthread_setcancelstate, pthread_setcanceltype - set cancelability state and type
SYNOPSIS
#include <pthread.h>
int pthread_setcancelstate(int state, int *oldstate);
3.pthread_testcancel
设置一个取消点
NAME
pthread_testcancel - request delivery of any pending cancellation request
SYNOPSIS
#include <pthread.h>
void pthread_testcancel(void);
4.线程分离
NAME
pthread_detach - detach a thread
SYNOPSIS
#include <pthread.h>
int pthread_detach(pthread_t thread);
分离一个线程,与之毫无关系,如果调用join会报错