1, critical area: Through the serialization of multithreading to access public resources or a piece of code, fast, suitable for controlling data access. Only one thread is allowed to access the shared resource at any time, and if more than one thread attempts to access the public resource, the other threads that attempt to access the public resource will be suspended after one thread enters, and wait until the thread that enters the critical section leaves and the critical section is freed before other threads can preempt it.
2, Mutex: adopt mutually exclusive object mechanism. Only the thread that owns the mutex has access to the public resource, because there is only one mutex object, so that the public resources are not accessed by multiple threads at the same time. Mutual exclusion can not only realize the common resources security sharing of the same application, but also realize the security sharing of common resources of different applications.
3. Semaphore: It allows multiple threads to access the same resource at the same time, but needs to limit the maximum number of threads that access this resource at the same time
4, Event: The way to keep the thread synchronized by notification operation, also can facilitate the operation of priority comparison of multiple threads.
The role of two parameters in the main function
The first parameter argc is an integer variable, and the second parameter argv is an array of pointers whose elements point to the character type
Data.
Using the main function with parameters, you can get the parameter values directly from the command line (these values are strings), and the program runs
, the corresponding processing can be done according to the different conditions in the input command line. Use the parameters in the main function to make
The program obtains the required data from the system, increasing the flexibility of handling the problem.