C# multi-threaded recording
C# multi-threaded recording In development, we often encounter different businesses accessing the same data source, and the execution flow of each business is a thread. At this time, if there are too many threads, multi-threading will occur and it is most likely to be encountered. The problem – concurrency. What is concurrency? To give a very classic example: in programs we often have to operate some objects, especially data in memory For example, the current entry condition has determined that newModel is not empty, and sleep(10) is a relatively time-consuming operation. During this period, if newModel is left empty elsewhere, an exception will occur when sleep(10) ends. Sleep here is just an enlarged time. In actual business, most of this operation is at the millisecond or even microsecond level. It is difficult to find problems in this area without code review, which leads to various inexplicable exceptions in the project. How Solving concurrency? There are many online tutorials on concurrency solutions, mainly locking, and the combination of design mode and singleton mode to solve concurrency problems. I won’t give detailed examples here for the time being. Collection data in memory may be saved in list, array, queue, etc., but…