Readerwriterlock is used to synchronize access to resources. At any specific time, it allows multiple threads to simultaneously read or write data to a single thread. When resources do not change frequently, readerwriterlock provides a higher throughput than simply allowing only one thread lock (such as monitor) at a time. Readerwriterlock has the best performance when most access requests are read requests and the Write Access frequency is low and the duration is short. Multiple read threads and a single write thread are operated in turn, so neither the read thread nor the write thread will be blocked for a long time. The read and write threads are respectively added to their respective queues. When the thread releases the write thread lock, all the waiting threads in the read thread queue will be granted the read thread lock. When all the read thread locks have been released, the next thread in the write thread queue in the waiting state (if any) will be granted the write thread lock, and so on. In other words, readerwriterlock operates alternately between a set of read threads and a write thread. 6. Think of another one: how the main thread waits for all the tasks thrown into the thread pool to be executed.. Net semaphores + waitall is not easy to use, because you can only wait for 64 threads at most. Someone wrote a countdownlutch last time. net 4.0 has a large number of lightweight sub-class libraries, such as semaphoreslim, spinlock, and spinwait, you do not have to write the CLR via C # 2nd statement as before. The maximum number of worker threads for each CPU is 25. Have you entered 250 wrong. net 3.5 SP1 becomes 250 ,. NET 2.0 is 25 ., For common Windows applications (such as the console or winform/WPF), the number of processors is set to * 250 ". That is to say, if your machine has two 2-core CPUs, the maximum capacity of the CLR thread pool is 1000 by default. That is to say, it can manage up to 1000 threads at the same time-in many cases this is already a terrible number, if you think this is not enough, then you should consider whether your implementation method can be improved. The improved version of smartthreadpool threadpool is good. Math. round (124.9999) = 125 only when the rounded digit is 5 will the parity of the previous digit be considered, that is, math. round (124.5) = 124 at the same time, consider the next few digits, such as math. round (124.51) = 125 when the financial software is required, it is best to change all the money into ingredients and calculate math in minutes. round is not accurate. To be accurate, you can use it. Sqldecimal AA = 123.325 m; // create a variable AA = sqldecimal. converttoprecscale (AA, 12, 2); // set the variable length to 12 bits. If the decimal point is 2 bits, set the "Basic Data" to "Minute ", individual users are even set to "PCT ". Only in summary, display, printing, you can use tens of thousands of units (scale according to customer needs ). Otherwise, an error occurs. This is also an experience.
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.