VC学习一日一练(3)---MFC中使用多线程技术

创建线程函数:

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

Parameters
lpThreadAttributes
[in] 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.
The lpSecurityDescriptor member of the structure specifies a security descriptor for the new thread. If lpThreadAttributes is NULL, the thread gets a default security descriptor. The ACLs in the default security descriptor for a thread come from the primary token of the creator.

dwStackSize
[in] 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. 
//设置线程初始栈的大小,即线程可以将多少地址空间用于它自己的栈,以字节为单位,系统会把这个参数四舍五入为最近页面的大小。
//页面是OS管理内存时使用的内存单位,不同CPU其页面大小不同,x86使用的页面大小是4KB。当保留地址空间的一块区域的同时,系统
//确保该区域的大小是系统页面大小的倍数

lpStartAddress
[in] Pointer to the application-defined function to be executed by the thread and represents the starting address of the thread.

lpParameter
[in] Pointer to a variable to be passed to the thread. //指向传递给线程的变量

dwCreationFlags
[in] Flags that control the creation of the thread. If the CREATE_SUSPENDED flag is specified, the thread is created in a suspended state, and will not run until the ResumeThread function is called. If this value is zero, the thread runs immediately after creation.

lpThreadId
[out] Pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is not returned.
//接收thread identifier(线程标示符,线程ID)的指针
Windows Me/98/95:  This parameter may not be NULL. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值