C++ 多线程之创建多线程CreateThread

一、为什么要写这篇博客

一直对C++多线程一知半解,感觉没有实际进入过C++多线程的世界,因此想从头开始慢慢真正进入C++多线程,真正了解多线程。因为我也想了解Linux下的C++ 编程,因此我也会在Linux平台下进行编写代码并验证。文章里面会借鉴一些网上优秀的代码和讲解,但买一行代码我都会自己敲一遍,学习和借鉴是一起的,但代码必须是自己一行一行写的才行。这里的开头也是希望自己能记住自己的初衷!

二、核心代码(Win32平台)

相关头文件

 #include <windows.h>

相关函数介绍

HANDLE WINAPI CreateThread(
_In_opt_        LPSECURITY_ATTRIBUTES           lpThreadAttributes,
_In_            SIZE_T                          dwStackSize,
_In_            LPTHREAD_START_ROUTINE          lpStartAddress,
_In_opt_        LPVOID                          lpParameter,
_In_            DWORD                           dwCreationFlags,
_Out_opt_   LPDWORD                             lpThreadId
);

参数:

lpThreadAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpThreadAttributes is NULL, the handle cannot be inherited.(该参数是一个指向 SECURITY_ATTRIBUTES 的指针,这个指针决定创建的该线程句柄是否被子进程继承,如果该参数为NULL,则表示该句柄不能被继承)。
dwStackSize [in]
The initial size of the stack, in bytes. The system rounds this value to the nearest page. If this parameter is zero, the new thread uses the default size for the executable(初始化栈的大小&

  • 3
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值