首页 > 编程语言 > 详细

windows多线程

时间:2021-04-10 22:26:00      阅读:21      评论:0      收藏:0      [点我收藏+]
#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休眠。参数为 休眠时间。

windows多线程

原文:https://www.cnblogs.com/hhhahh/p/14642133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!