一.创建线程函数
     常用的创建线程的函数是CreateThread,还有MFC中的AfxBeginThread方法.另一种函数是_beginthreadex,
其实它在内部调用了CreateThread,在调用之前_beginthreadex做了很多的工作,从而使得它比CreateThread更
安全.所以一般使用_beginthreadex来创建线程.于是以下使用_beginthreadex函数来创建线程类.

二.线程类示例
1.Thread.h文件如下:
线程类封装#ifndef _THREAD_H__
线程类封装#define _THREAD_H__
线程类封装#include <process.h>
线程类封装#include <windows.h>
线程类封装
线程类封装class CThread

2.Thread.cpp文件如下:
线程类封装#include "Thread.h"
线程类封装
线程类封装
线程类封装CThread::CThread()

三.线程类的使用
1. 新建一个win32控制台工程,代码如下:
线程类封装#include "Thread.h"
线程类封装#include <iostream>
线程类封装#include <conio.h>
线程类封装
线程类封装
线程类封装using namespace std;
线程类封装
线程类封装
线程类封装class CMyThread:public CThread

相关文章:

  • 2021-07-14
  • 2021-06-04
  • 2022-01-13
  • 2022-12-23
  • 2022-01-28
  • 2021-06-05
  • 2022-12-23
  • 2022-01-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-06-24
  • 2021-12-09
  • 2021-05-26
  • 2021-05-21
相关资源
相似解决方案