Readerwriterlock in. net

Source: Internet
Author: User
Original article: 2008-02-18

This article is Based on. NET 2.0

Readerwriterlock may be used in multi-threaded programming environments. Readerwriterlock's usage and how to use.

How readerwriterlock is implemented, or when different lock requests are met at the same time, and how readerwriterlock is handled, which is not mentioned in the above article may be a bit confusing for users. Compared with the Read and Write locks in the database, it is easy to understand. The following describes two threads.
There are four types of requests in the order of arrival
Reader-reader. The second reader directly obtains read control without waiting;
Reader-writer, the second must wait until the first call releasereaderlock () to release the read control before obtaining the write control;
Writer-Writer. The second one needs to wait for the first call releasewriterlock () to release write control before obtaining write control;
Writer-reader. The second one needs to wait for the first call releasewriterlock () to release write control before obtaining read control.
The actual situation may be more than two threads, for more information, please read this article http://www.rainsts.net/article.asp? Id = 171

If you think readerwriterlock is not easy to use, can you read this article http://www.cnsdn.com.cn/blog/article.asp? Id = 1972. The conversion from readerlock to writerlock (upgradetowriterlock) is not atomic, and an alternative lockfree method and its implementation are introduced. In addition, the "performance is very poor" mentioned in this article, which is not described in detail by the author; I use readerwriterlock less often and it is unclear whether it is really bad.

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.