1.windows Threads
A Windows thread is an instance of code that can be executed. The system dispatches the program on a thread-by-unit.
A program can have multiple threads for multitasking.
Features of 2.windows threads
(1) thread has an ID
(2) thread has its own security attributes
(3) Each thread has its own memory stack
(4) Each thread has its own register information
3. Process multi-tasking and threading multitasking
Process multitasking: Each process uses a private address space
Thread multitasking: Multiple threads within a process use the same address space
Thread invocation: Divides the execution time of the CPU into a time slice, sequentially executing different threads according to the time slice
Thread polling: Thread A, thread B-a ...
4. Thread Usage
(1) Defining threading functions
DWORD WINAPI ThreadProc (LPVOID lpparameter);
(2) Create thread
HANDLE CreateThread (lpsecurity_attributes lpthreadattributes,//Security properties
size_t dwstacksize,//thread stack size
Lpthread_start_routine lpstartaddress,//thread handling function address
LPVOID Lpparameter,//parameters passed to the threading function
DWORD dwcreationflags,//Creation mode
Lpdword Lpthreadid); Create successful, return thread ID
27.windows Threads