Windows Multithreading Sample
来源:互联网 发布:动态域名解析软件 编辑:程序博客网 时间:2024/05/16 08:28
说明:
最近项目除了需要用到渲染的知识,还涉及socket与multithreads,做如下多线程程序总结
参考书籍:《Multithreading Application in Win32》 Jim Beveridge & Robert
/* * File name : MultiThreads.cpp * Last updated date : 2011.9.19 * Author : Dormy.ET.C * Description : * * 1.释放核心对象API - closeHandle() * 2.获取退出代码API - GetExitCodeThread() * 3.完全强制中断线程API - ExitThread() * */#define WIN32_LEAN_AND_MEAN#include <Windows.h>#include <stdio.h>#include <stdlib.h>#include <conio.h>DWORD WINAPI ThreadFunc(LPVOID);void ThreadSubFunc(void);#define MAX_THREADS 256int main(int argc, char *argv[]){HANDLE hThread;DWORD exitCode = 0;DWORD threadID;hThread = ::CreateThread(NULL, 0, ThreadFunc, (LPVOID)1, 0, &threadID);if( hThread )printf("Thread launched !\n");while(1){BOOL rc;rc = ::GetExitCodeThread(hThread, &exitCode);if( rc && exitCode != STILL_ACTIVE ) break;}::CloseHandle(hThread);printf("Thread returned %d\n", exitCode);::system("Pause");return EXIT_SUCCESS;}DWORD WINAPI ThreadFunc(LPVOID n){printf("Thread running !\n");ThreadSubFunc();return 0;}void ThreadSubFunc(void){printf("About to exit thread !\n");::ExitThread(4);// 以下语句永远不会执行printf("Never print this line\n");}
- Windows Multithreading Sample
- multithreading
- Simple Windows Service Sample
- Simple Windows Service Sample
- Safe, Simple Multithreading in Windows Forms 3 Part
- Safe, Simple Multithreading in Windows Forms, Part 1
- Safe, Simple Multithreading in Windows Forms, Part 2
- Safe, Simple Multithreading in Windows Forms, Part 3
- Windows 8.1 Sample中的Media相关的Sample
- sample
- !!!sample
- sample
- Using the Windows Forms XML Parser Sample
- An GPSID sample code for Windows Mobile
- Sample of QuickTime API on Windows
- Windows Vista Sample Credential Providers Overview 中文翻译
- Windows MiniFilter驱动 - Sample(1)
- Python27 with Oracle Sample(Windows OS)
- STL之vector使用
- xml的简单了解
- ass字幕格式
- MFC第三天——RTTI & Dynamic Creation
- 判断单链表是否存在环型链表问题
- Windows Multithreading Sample
- 点击CComboBox控件的下拉按钮控制下拉框ListBox的显示和隐藏
- 淘宝广告搜索平台部面试
- C++ Primer Plus学习:第十二章 类和动态内存(3)
- C#如何创建Execel文件
- 多线程与多进程
- STM32 与 enc28j60 接口
- Linq to excel 你听说过吗?
- ActiveReport 预览正常但打印输出空白页的解决方案