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. 

你可能感兴趣的:(VC学习一日一练(3)---MFC中使用多线程技术)