C++ 多线程问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 01:13:06
如何在C++中实现多线程?比如说在一个线程在屏幕上打印1到100的每个数字,第2个线程在屏幕上打印从200到300的每个数字,最好有完整的C++程序,谢谢啦:)

#define WIN32_LEAN_AND_MEAN included correctly

#include <windows.h>
#include <windowsx.h>
#include <conio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>

// DEFINES ////////////////////////////////////////////////////////////////////////////////

// PROTOTYPES /////////////////////////////////////////////////////////////////////////////

DWORD WINAPI Printer_Thread(LPVOID data);

// GLOBALS ////////////////////////////////////////////////////////////////////////////////

// FUNCTIONS //////////////////////////////////////////////////////////////////////////////

DWORD WINAPI Printer_Thread(LPVOID data)
{
// this thread function simply prints out data 25 times with a slight delay

for (int index=0; index<25; index++