标签:style class blog code http color
#include <unistd.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> void cleanup() { printf("cleanup\n"); } void *test_cancel(void) { pthread_cleanup_push(cleanup,NULL); printf("test_cancel\n"); while(1) { printf("test message\n"); sleep(1); } pthread_cleanup_pop(0); } int main() { pthread_t tid; pthread_create(&tid,NULL,(void *(*)(void *))test_cancel,NULL); sleep(2); pthread_cancel(tid); pthread_join(tid,NULL); return 0; }
标签:style class blog code http color
原文地址:http://www.cnblogs.com/lakeone/p/3789274.html