#include <windows.h>
#include <process.h>
#include <iostream>
using namespace std;
void func(void *s) {
cout << "子线程" << endl;
_endthread();
}
int main() {
_beginthread(func, 0, NULL);
Sleep(10);
cout << "主线程" << endl;
return 0;
}
介绍:
1、_beginthread 函数创建一个在 start_address 开始执行例程的线程。
函数语法:
uintptr_t _beginthread(
void( __cdecl *start_address )( void * ),
unsigned stack_size,
void *arglist
);
参数介绍:
stack_size
新线程的堆栈大小或 0。
arglist
要传递到新线程的参数列表,或为 NULL。
start_address
启动开始执行新线程的例程的地址。
2、_endthread 会自动关闭线程句柄。无参。
3、Sleep休眠。参数为 休眠时间。
原文:https://www.cnblogs.com/hhhahh/p/14642133.html