Windows Programming Learning

Source: Internet
Author: User

1. Methods of multithreading synchronization

A) entercirticalsection leaveciriticalsection

b) Mutex mutex object WaitForSingleObject ReleaseMutex use method and the above one similar

c) CreateEvent WaitForSingleObject SetEvent The event object into a trusted state resetevent the event object to become untrusted, and through these two settings to control the execution of the thread waiting for the event object

d) Semophore and the above several single entry control is different, Semophore is to control multiple parallel portals, when these multiple entrances are occupied, Semophore objects become blocked state, So once the thread has finished working on the related tasks, remember to call Releasesemophore to release the resources

e) Waitformultiobject waits for more than one kernel object, and only these multiple kernel objects become trusted, and subsequent code can be executed.

2. About thread-local storage

Each thread has its own array, with a maximum length of 1000

Each time TlsAlloc finds an available index and then returns, then each thread in the process can call TlsGetValue or TlsSetValue with this index parameter to read and write the array elements of the corresponding index. Although threads can have the same index as arguments, this does not conflict because they all manipulate only the array associated with this thread

You can set the value of an array item of a specific index in the respective array without the index TlsSetValue provided by TlsAlloc

Windows Programming Learning

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.