创建线程
什么是线程
- 线程是附属在进程上的执行实体,是代码的执行流程。
- 一个进程可以包含多个线程,但是一个进程至少要包含一个线程。
- 单核CPU可以执行多线程程序
创建线程CreateThread
Creates a thread to execute within the virtual address space of the calling process.
To create a thread that runs in the virtual address space of another process, use the CreateRemoteThread function.
HANDLE WINAPI CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize, //初始堆栈,不填写系统给一个默认的堆栈
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);