Introduction - If you have any usage issues, please Google them yourself
Thread mutual exclusion. Create a new thread in the main function, and then the main thread shares the same variable with the new thread, such as sum. In the main function, a loop statement is written in a total cycle of 20 times, and the value of the sum is first added to 1 in each loop and then dormant for 1 milliseconds. In the new thread, also milliseconds. In the new thread, a circular statement is also written, which has 20 cycles altogether. In each cycle, assign sum to a temporary variable t first, then add t to 1, then sleep 1 milliseconds, and finally assign the value of t to sum. When all of the work is done, the value of the sum is printed in the main function.