Method and device for preventing thread from blocking
Patent Information
- Authority / Receiving Office
- CN Β· China
- Current Assignee / Owner
- TENCENT TECH (SHENZHEN) CO LTD
- Publication Date
- 2013-08-14
Smart Images
Figure 1 Figure 2 Figure 3
Abstract
Description
technical field
[0001] The invention relates to computer technology, in particular to a method and device for preventing thread from blocking. Background technique
[0002] Each program running on the system is a process, and each process can include one or more threads, and a thread is the smallest unit of program execution flow.
[0003] The execution order of instructions within each thread is fixed. figure 1 It is a schematic diagram of an instruction execution method in an existing thread. Such as figure 1 As shown, instruction 1 is executed first, then instruction 2 is executed, and so on until instruction n is executed (assuming n is greater than 2), and the process ends.
[0004] Generally, a program including a plurality of threads is called a multi-threaded program. In a multi-threaded program, when multiple threads need to access the same piece of data, that is, shared data, because the order of execution of instructions is different, locks are required to imp...