27.windows Threads

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.