Windows下pthread多线程使用(4):CancelThread
来源:互联网 发布:资产证券化 知乎 编辑:程序博客网 时间:2024/05/23 11:49
声明同这篇文章,以下是代码
#include <cmnheader.h>void *theThread(void *param){printf("Thread: Entered\n");while (1){printf("Thread: Looping or long running request\n");pthread_testcancel();Sleep(1);}return NULL;}int main(int argc, char **argv){pthread_t thread;int rc = 0;void *status;printf("Enter Testcase - %s\n", argv[0]);printf("Create/start a thread\n");rc = pthread_create(&thread, NULL, theThread, NULL);checkResults("pthread_create()\n", rc);printf("Wait a bit until we 'realize' the thread needs to be canceled\n");Sleep(3);rc = pthread_cancel(thread);checkResults("pthread_cancel()\n", rc);printf("Wait for the thread to complete, and release its resources\n");rc = pthread_join(thread, &status);checkResults("pthread_join()\n", rc);printf("Thread status indicates it was canceled\n");if (status != PTHREAD_CANCELED) {printf("Unexpected thread status\n");}printf("Main completed\n");system("pause");return 0;}
0 0
- Windows下pthread多线程使用(4):CancelThread
- Windows下pthread多线程使用(1):准备工作
- Windows下pthread多线程使用(2):CreateThread
- Windows下pthread多线程使用(3):ExitThread
- Windows下pthread多线程使用(5):WaitForAnEnd
- Windows下使用pthread
- Windows下使用pthread
- windows 下使用 pthread
- Windows下使用pthread
- Windows下使用pthread
- windows 下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- windows下使用pthread
- Windows下使用pthread
- Windows下使用pthread
- windows下使用pthread库
- PB --TreeView实现同步选择
- Eclipse使用入门教程
- 九度Online Judge上部分题目代码
- Qt中图像的显示与基本操作
- UVA 10652 Board Wrapping 凸包模板
- Windows下pthread多线程使用(4):CancelThread
- VIM常用操作(常用操作自维护)
- 基于Qt for Android联想到调用Android API
- 源码下 编译apk 混淆
- 2014-04-17多益游戏实习生招聘(游戏技术方向)题目及解析
- RAC grid安装检查报错Result: PRVF-4007 : User equivalence check failed for user "oracle"
- android 反编译
- Qt图片显示效率的比较
- Gray Code