Thread: A thread is a separate unit of execution for a process, and each process has a main thread, except that the main path can contain other threads.
The meaning of Multithreading: multithreading helps to improve the overall responsiveness of the program and improve the efficiency of the CPU.
Multithreaded application domains are quite unstable because multiple threads can run shared function modules at the same time. To protect the resources of the application from being destroyed, there are three locking mechanisms available for multithreaded programs, namely the Monitor class, the lock keyword, and the mutex class.
1. Lock
Lock implements the ability to make a post-entry thread that does not break the current thread, but instead waits for the current thread to end before it resumes execution.
Application:
The code is as follows:
Private Object Thislock=new object ();
Lock (Thislock) {
Locked block of code
}
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
Lock, Monitor, mutex learning notes in C #
This address: http://www.paobuke.com/develop/c-develop/pbk23177.html
Related content time-processing in C # JavaScriptSerializer serialization C # interface in derived classes and external classes call Method Example C # boxed and unboxing Knowledge Review C # WinForm determine if the program is already running, and only allow one instance to run, with the source code
C # Implementing a subform with a parent form communication Method Instance Summary C # editingcontrolshowing event usage Instance in DataGridView C # winfrom Default Input method settings in C # Implementation of the Baidu site collection and ranking query function ideas and examples
Lock, Monitor, mutex learning notes in C #