WO2019061619A1 - 一种避免线程阻塞的方法、装置及计算机设备 - Google Patents

一种避免线程阻塞的方法、装置及计算机设备 Download PDF

Info

Publication number
WO2019061619A1
WO2019061619A1 PCT/CN2017/107783 CN2017107783W WO2019061619A1 WO 2019061619 A1 WO2019061619 A1 WO 2019061619A1 CN 2017107783 W CN2017107783 W CN 2017107783W WO 2019061619 A1 WO2019061619 A1 WO 2019061619A1
Authority
WO
WIPO (PCT)
Prior art keywords
public variable
thread
variable
data
tls
Prior art date
Application number
PCT/CN2017/107783
Other languages
English (en)
French (fr)
Inventor
刘吉林
陈少杰
张文明
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019061619A1 publication Critical patent/WO2019061619A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms

Definitions

  • the invention belongs to the technical field of Internet live broadcasting, and in particular relates to a method, a device and a computer device for avoiding thread blocking.
  • the producer consumer mode is generally used, that is, using multiple threads to acquire data (ie, "producer thread"), one thread is taken out of the producer-generated data block and then processed (“consumer thread”) ).
  • program thread multiple threads to acquire data
  • consumer thread one thread is taken out of the producer-generated data block and then processed
  • the problem that must be encountered is the mutual exclusion of multiple threads to a public variable. And when the number of threads increases, it is easy to block, affecting program performance.
  • the present invention provides a method, a device, and a computer device for avoiding thread blocking, which are used to solve the problem in the prior art when a thread is used to process a message, and when the thread is increased, the thread is easy to be used.
  • the embodiment of the invention provides a method for avoiding thread blocking, the method comprising:
  • TLS Thread Local Storage
  • the public variable class further includes: a member variable and a locked critical variable.
  • the first modification function ThreadStatic and the second modification function static are used to modify the public variable class to obtain a modified instance.
  • the modified instance is assigned to the TLS variable to form the TLS public variable.
  • the controlling each producer thread to write data by using the corresponding TLS public variable includes:
  • the first target memory is a memory in which the storage identifier is consistent with the data type identifier
  • the data to be written is written into the first target memory using a write data function.
  • the controlling consumer thread uses the TLS public variable in the consumer variable list to read data, including:
  • the second target memory Determining, according to the data type identifier of the flipped member variable, the second target memory, wherein the second target memory is a memory that stores the identifier and the inverted data type identifier;
  • the second target memory is different from the first target memory.
  • the embodiment of the invention further provides an apparatus for avoiding thread blocking, the apparatus comprising:
  • An obtaining unit configured to instantiate the public variable class, obtain a thread to locally store a TLS public variable, and store the TLS public variable in a pre-established list of consumer variables;
  • a first control unit configured to control each producer thread to write data by using the corresponding TLS public variable
  • a second control unit configured to control the consumer thread to use the TLS public variable in the consumer variable list to read data.
  • the embodiment of the invention further relates to a computer readable storage medium having stored thereon a computer program, the program being executed by the processor to implement the following steps:
  • TLS public variables are stored in a pre-established list of consumer variables
  • the embodiment of the invention further provides a computer device for avoiding thread blocking, comprising:
  • At least one processor At least one processor
  • At least one memory communicatively coupled to the processor, wherein
  • the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of the above.
  • Embodiments of the present invention provide a method, an apparatus, and a computer device for avoiding thread blocking.
  • the method includes: establishing a corresponding public variable class for each producer thread, where the public variable class includes two memories;
  • the variable class is instantiated, the thread is locally stored to store the TLS public variable, and the TLS public variable is stored in a pre-established list of consumer variables;
  • each producer thread is controlled to use the corresponding TLS public variable to write data;
  • the consumer thread uses the TLS public variable in the list of consumer variables to read data; thus, a common variable class is created for each producer thread, thus ensuring that only two threads are always mutually exclusive access;
  • mutual exclusion access since the public variable class contains two memories, the read and write operations can be performed separately in the two memories, so that the producer thread does not need to wait for the consumer thread to complete the data operation after the data is completed. , thereby avoiding producer thread blocking, improving the throughput of the program, and improving the process. Performance.
  • FIG. 1 is a schematic flowchart of a method for avoiding thread blocking according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for avoiding thread blocking according to Embodiment 2 of the present invention
  • FIG. 3 is a schematic structural diagram of a computer device for avoiding thread blocking according to Embodiment 3 of the present invention.
  • the embodiment of the present invention provides a method for avoiding threads by solving the problem that the thread is prone to blockage and the program performance is affected when the thread is processed by the thread in the prior art.
  • Blocking method, device and computer device the method comprising: establishing a corresponding public variable class for each producer thread, the public variable class comprising two memories; instantiating the public variable class to obtain a thread local Storing a TLS public variable and storing the TLS public variable in a pre-established list of consumer variables; controlling each producer thread to write data using the corresponding TLS public variable; controlling consumer threads to utilize the consumer variable In the list
  • the TLS public variable performs reading data.
  • This embodiment provides a method for avoiding thread blocking. As shown in FIG. 1, the method includes:
  • the public variable class ProducerData includes two memories, which may be DataA and DataB. It also includes a member variable bool flag and a locking critical variable Object obj; the bool is a data type, and the flag is Data type identifier, the data type includes: True, referred to as T; and Flase, referred to as F.
  • the write data function PushData(T d) of the public variable class ProducerData and the fetch data function PopData() of the public variable class ProducerData are created.
  • the write data function PushData(Td) will be called by the producer thread to write data to the memory.
  • the fetch data function of the public variable class ProducerData is created, and the fetch data function PopData() is called by the consumer thread to read the data in the memory.
  • the public variable class is modified in turn by using the first modification function ThreadStatic and the second modification function static to obtain a modified instance;
  • the modified instance is assigned to the TLS variable to form the TLS public variable.
  • each producer thread is controlled to write data by using the corresponding TLS public variable; specifically, the write data function PushData (T d) in the TLS public variable is called to write data.
  • each memory has a different storage identifier, and the storage identifier corresponds to the data type identifier, so it is necessary to determine the first target memory according to the data type identifier.
  • the data to be written is written into the first target memory by using a write data function PushData (T d).
  • the memory can be determined according to the following function:
  • the lock critical variable performs a lock operation on the write data process.
  • the critical variable obj must be a variable within the common variable class ProducerData.
  • the consumer thread is controlled to read data by using the corresponding TLS public variable; specifically, the data function PopData() in the TLS public variable is called to read the data.
  • the consumer thread modifies the locking of the data and flips the data type identifier of the member variable. Among them, the modified lock is only recognized by the current consumer thread, avoiding other consumer threads competing for data resources in the process of reading data.
  • the data type identifier of the flip member variable is such that the read and write operations of the current cycle and the read and write operations of the next cycle are performed in the opposite memory to avoid blockage of the producer thread.
  • the flipped program is implemented as follows:
  • the producer thread writes data in DataA
  • the consumer thread reads the data in DataB
  • the producer thread writes the data in DataB in the next cycle.
  • the consumer thread reads the data in DataA.
  • the producer thread can write data to another memory regardless of whether the consumer thread has finished reading, that is, the producer thread waits for at most one flip time. Write data operations can be implemented, reducing the waiting time of the producer thread, thereby avoiding the producer thread blocking, improving the throughput of the program, and thus improving the program performance.
  • the data function PopData() is called to read the data.
  • the second target memory for reading the data is determined according to the data type identifier of the flipped member variable; and the data function PopData() is used to obtain the second target memory. Reading data, wherein the second target memory is a memory that stores an identifier that is consistent with the inverted data type identifier; the second target memory is different from the first target memory.
  • the memory can be determined according to the following function:
  • the storage identifier of the DataB is consistent with the data type identifier after the rollover, it can be determined that the DataB is the target storage, and the producer thread can write the data to the DataB. This prevents the same data from being read and written simultaneously.
  • the second target memory is emptied.
  • the embodiment further provides a device for avoiding thread blocking.
  • the device includes: an establishing unit 21, an obtaining unit 22, a first control unit 23, and a second control unit 24; among them,
  • the building unit 21 needs to establish a corresponding public variable class ProducerData for each producer thread, so that each producer The thread corresponds to a public variable class ProducerData.
  • the public variable class ProducerData includes two memories, which may be DataA and DataB. It also includes a member variable bool flag and a locking critical variable Object obj; the bool is a data type, and the flag is Data type identifier, the data type includes: True, referred to as T; and Flase, referred to as F.
  • the write data function PushData(T d) of the public variable class ProducerData and the fetch data function PopData() of the public variable class ProducerData are created.
  • the write data function PushData(Td) will be called by the producer thread to write data to the memory.
  • the fetch data function of the public variable class ProducerData is created, and the fetch data function PopData() is called by the consumer thread to read the data in the memory.
  • the obtaining unit 22 is configured to instantiate the public variable class, obtain a thread to locally store the TLS public variable, and store the TLS public variable in a pre-established list of consumer variables;
  • the obtaining unit 22 sequentially modifies the public variable class by using the first modification function ThreadStatic and the second modification function static to obtain a modified instance.
  • the modified instance is assigned to the TLS variable to form the TLS public variable.
  • the first control unit 21 is configured to control each producer thread to write data using the corresponding TLS public variable.
  • the first control unit 21 calls the write data function PushData (T d) in the TLS common variable to write data.
  • each memory has a different storage identifier, and the storage identifier corresponds to the data type identifier, so it is necessary to determine the first target memory according to the data type identifier.
  • the data to be written is written into the first target memory by using a write data function PushData (T d).
  • the memory can be determined according to the following function:
  • the lock critical variable performs a lock operation on the write data process.
  • the critical variable obj must be a variable within the common variable class ProducerData.
  • the second control unit 24 is then configured to control the consumer thread to read data using the TLS public variable in the list of consumer variables.
  • the second control unit 24 invokes the fetch data function PopData() in the TLS public variable to read the data.
  • the consumer thread modifies the locking of the data and flips the data type identifier of the member variable. Among them, the modified lock is only recognized by the current consumer thread, avoiding other consumer threads competing for data resources in the process of reading data.
  • the data type identifier of the flip member variable is such that the read and write operations of the current cycle and the read and write operations of the next cycle are performed in the opposite memory to avoid blockage of the producer thread.
  • the flipped program is implemented as follows:
  • the producer thread writes data in DataA
  • the consumer thread reads the data in DataB
  • the producer thread writes the data in DataB in the next cycle.
  • the consumer thread reads the data in DataA.
  • the producer thread can write data to another memory regardless of whether the consumer thread has finished reading, that is, the producer thread waits for at most one flip time. Write data operations can be implemented, reducing the waiting time of the producer thread, thereby avoiding the producer thread blocking, improving the throughput of the program, and thus improving the program performance.
  • the data function PopData() is called to read the data.
  • the second target memory for reading the data is determined according to the data type identifier of the flipped member variable; and the data function is used again.
  • PopData() reads data from the second target memory, wherein the second target memory is a memory that stores a tag that is consistent with the inverted data type identifier; the second target memory is different from the first target memory.
  • the memory can be determined according to the following function:
  • the storage identifier of the DataB is consistent with the data type identifier after the rollover, it can be determined that the DataB is the target storage, and the producer thread can write the data to the DataB. This prevents the same data from being read and written simultaneously.
  • the second target memory is emptied.
  • the embodiment further provides a computer device for avoiding thread blocking.
  • the computer device includes: a radio frequency (RF) circuit 310, a memory 320, an input unit 330, a display unit 340, and an audio circuit 350. , WiFi module 360, processor 370, and power supply 380 and other components.
  • RF radio frequency
  • FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • the RF circuit 310 can be used for receiving and transmitting signals, and in particular, receiving downlink information of the base station and processing it to the processor 370.
  • RF circuit 310 includes, but is not limited to, at least one amplifier, transceiver, coupler, Low Noise Amplifier (LNA), duplexer, and the like.
  • LNA Low Noise Amplifier
  • the memory 320 can be used to store software programs and modules, and the processor 370 executes various functional applications and data processing of the computer devices by running software programs and modules stored in the memory 320.
  • the memory 320 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function, and the like; the storage data area may store data created according to usage of the computer device, and the like.
  • memory 320 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 330 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the computer device.
  • the input unit 330 can include a keyboard 331 and other input devices 332.
  • the keyboard 331 can collect input operations of the user thereon and drive the corresponding connecting device according to a preset program.
  • the keyboard 331 collects the output information and sends it to the processor 370.
  • the input unit 330 may also include other input devices 332.
  • other input devices 332 may include, but are not limited to, one or more of a touch panel, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 340 can be used to display information input by the user or information provided to the user as well as various menus of the computer device.
  • the display unit 340 can include a display panel 341.
  • the display panel 341 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the keyboard 331 can cover the display panel 341. When the keyboard 331 detects a touch operation on or near it, the keyboard 331 transmits to the processor 370 to determine the type of the touch event, and then the processor 370 displays the panel according to the type of the input event. A corresponding visual output is provided on the 341.
  • the keyboard 331 and the display panel 341 are implemented as two separate components in FIG. 3 to implement the input and input functions of the computer device, in some embodiments, the keyboard 331 can be integrated with the display panel 341 to implement the computer device. Input and output functions.
  • An audio circuit 350, a speaker 351, and a microphone 352 can provide an audio interface between the user and the computer device.
  • the audio circuit 350 can transmit the converted electrical data of the received audio data to the speaker 351, and convert it into a sound signal output by the speaker 351;
  • WiFi is a short-range wireless transmission technology.
  • the computer device can help users to send and receive emails, browse web pages and access streaming media through the WiFi module 360. It provides users with wireless broadband Internet access.
  • FIG. 3 shows the WiFi module 360, it can be understood that it does not belong to the essential configuration of the computer device, and may be omitted as needed within the scope of not changing the essence of the invention.
  • Processor 370 is a control center for computer devices that connects various portions of the entire computer device using various interfaces and lines, by running or executing software programs and/or modules stored in memory 320, and recalling data stored in memory 320. , performing various functions and processing data of the computer device, thereby performing overall monitoring of the computer device.
  • the processor 370 may include one or more processing units; preferably, the processor 370 may integrate an application processor, wherein the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the computer device also includes a power source 380 (such as a power adapter) that powers the various components.
  • a power source 380 such as a power adapter
  • the power source can be logically coupled to the processor 370 via a power management system.
  • the method, the device and the computer device for avoiding thread blocking provided by the embodiments of the present invention have at least the following beneficial effects:
  • Embodiments of the present invention provide a method, an apparatus, and a computer device for avoiding thread blocking.
  • the method includes: establishing a corresponding public variable class for each producer thread, where the public variable class includes two memories;
  • the variable class is instantiated, the thread is locally stored to store the TLS public variable, and the TLS public variable is stored in a pre-established list of consumer variables;
  • each producer thread is controlled to use the corresponding TLS public variable to write data;
  • the consumer thread reads the data using the TLS public variable in the list of consumer variables; thus, creating a common variable class for each producer thread, thus ensuring that only two threads are always mutually exclusive access;
  • the public variable class contains two memories, it can be performed separately in two memories. Read and write operations, so that the producer thread does not need to wait for the consumer thread to complete the data operation after the data is completed, thereby avoiding the producer thread blocking, improving the throughput of the program, thereby improving the program performance.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processing (DSP) may be used in practice to implement some or all of the functionality of some or all of the gateways, proxy servers, systems in accordance with embodiments of the present invention.
  • DSP digital signal processing
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • Such a program implementing the present invention may be stored on a computer readable storage medium or may be in the form of one or more signals.
  • Such signals may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form; the program, when executed by the processor, implements the steps of: establishing a corresponding public variable class for each producer thread,
  • the public variable class contains two memories; instantiating the public variable class, obtaining a thread to locally store the TLS public variable, and storing the TLS public variable in a pre-established list of consumer variables; controlling each producer thread Writing data using the corresponding TLS public variable; controlling the consumer thread to read data using the TLS public variable in the consumer variable list.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种避免线程阻塞的方法、装置及计算机设备,方法包括:为各生产者线程建立相应的公共变量类,公共变量类中包含两个存储器(S101);对公共变量类进行实例化,获取TLS公共变量,并将TLS公共变量存储至预先建立的消费者变量列表中(S102);控制各生产者线程利用相应的TLS公共变量进行写数据(S103);控制消费者线程利用消费者变量列表中所述TLS公共变量进行读取数据(S104);这样就可保证始终只有两个线程发生互斥访问;而由于公共变量类中包含两个存储器,因此可以在两个存储器中分别进行读写操作,这样生产者线程就无需等待消费者线程取数据完毕之后再进行写数据操作,进而避免了生产者线程阻塞,进而提高了程序性能。

Description

一种避免线程阻塞的方法、装置及计算机设备 技术领域
本发明属于互联网直播技术领域,尤其涉及一种避免线程阻塞的方法、装置及计算机设备。
背景技术
在直播平台的开发过程中,经常会进行消息处理。
在消息处理时,一般会到生产者消费者模式,即使用多个线程获取数据(即“生产者线程”),一个线程从生产者产生的数据块中取出然后处理数据(“消费者线程”)。在这种模式下,必然会碰到的问题是多线程对一个公共变量的互斥读写。并且当线程增多时,易发生阻塞,影响程序性能。
发明内容
针对现有技术存在的问题,本发明实施例提供了一种避免线程阻塞的方法、装置及计算机设备,用于解决现有技术中当利用线程对消息进行处理时,当线程增多时导致线程易发生堵塞,进而影响程序性能的技术问题。
本发明实施例提供一种避免线程阻塞的方法,所述方法包括:
为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
对所述公共变量类进行实例化,获取线程本地存储(TLS,Thread Local Storage)公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
控制各生产者线程利用相应的所述TLS公共变量进行写数据;
控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
上述方案中,所述公共变量类中还包括:成员变量及加锁临界变量。
上述方案中,所述为各生产者线程建立相应的公共变量类,包括:
创建所述公共变量类的写数据函数;
创建所述公共变量类的取数据函数。
上述方案中,所述对所述公共变量类进行实例化,获取线程本地存储TLS 公共变量,包括:
利用第一修饰函数ThreadStatic及第二修饰函数static依次对所述公共变量类进行修饰,获取修饰实例;
将所述修饰实例赋值至所述TLS变量,形成所述TLS公共变量。
上述方案中,所述控制各生产者线程利用相应的所述TLS公共变量进行写数据,包括:
获取所述成员变量的数据类型标识;
将所述数据类型标识分别与两个所述存储器的存储标识进行比较,确定第一目标存储器;所述第一目标存储器为存储标识与数据类型标识一致的存储器;
利用写数据函数将待写数据写入所述第一目标存储器中。
上述方案中,所述利用写数据函数将所述待写数据写入所述目标存储器中时,利用所述加锁临界变量对写数据过程进行加锁操作。
上述方案中,所述控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据,包括:
对所述成员变量进行加锁,将所述成员变量的数据类型标识进行翻转;
根据翻转后的成员变量的数据类型标识确定第二目标存储器,所述第二目标存储器为存储标识与翻转后的数据类型标识一致的存储器;
利用取数据函数从所述第二目标存储器中读取数据;其中,
所述第二目标存储器与第一目标存储器不同。
本发明实施例还提供一种避免线程阻塞的装置,所述装置包括:
建立单元,用于为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
获取单元,用于对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
第一控制单元,用于控制各生产者线程利用相应的所述TLS公共变量进行写数据;
第二控制单元,用于控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
本发明实施例还一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:
为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所 述TLS公共变量存储至预先建立的消费者变量列表中;
控制各生产者线程利用相应的所述TLS公共变量进行写数据;
控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
本发明实施例还提供一种避免线程阻塞的计算机设备,包括:
至少一个处理器;以及
与所述处理器通信连接的至少一个存储器,其中,
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如上述任一所述的方法。
本发明实施例提供一种避免线程阻塞的方法、装置及计算机设备,所述方法包括:为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;控制各生产者线程利用相应的所述TLS公共变量进行写数据;控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据;如此,为每个生产者线程建立一个公共变量类,这样就可保证始终只有两个线程发生互斥访问;而在发生互斥访问时,由于公共变量类中包含两个存储器,因此可以在两个存储器中分别进行读写操作,这样生产者线程就无需等待消费者线程取数据完毕之后再进行写数据操作,进而避免了生产者线程阻塞,提高了程序的吞吐能力,提高了程序性能。
附图说明
图1为本发明实施例一提供的避免线程阻塞的方法流程示意图;
图2为本发明实施例二提供的避免线程阻塞的装置结构示意图;
图3为本发明实施例三提供的避免线程阻塞的计算机设备结构示意图。
具体实施方式
本申请实施例通过为了解决现有技术中当利用线程对消息进行处理时,当生产者线程增多时导致线程易发生堵塞,进而影响程序性能的技术问题,本发明实施例提供了一种避免线程阻塞的方法、装置及计算机设备,所述方法包括:为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;控制各生产者线程利用相应的所述TLS公共变量进行写数据;控制消费者线程利用所述消费者变量列表中的 所述TLS公共变量进行读取数据。
下面通过附图及具体实施例对本发明的技术方案做进一步的详细说明。
实施例一
本实施例提供一种避免线程阻塞的方法,如图1所示,所述方法包括:
S101,为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
为了避免多个生产者线程需要在向同一个数据块进行写数据操作,需要等待,导致生产者线程堵塞,本步骤中为各生产者线程建立相应的公共变量类ProducerData,使得每个生产者线程都对应一个公共变量类ProducerData。
首先定义公共变量类ProducerData,所述公共变量类ProducerData包含两个存储器,可以为DataA和DataB;还包括成员变量bool flag及加锁临界变量Object obj;所述bool为一个数据类型,所述flag为数据类型标识,所述数据类型包括:True,简称T;及Flase,简称F。
然后,创建所述公共变量类ProducerData的写数据函数PushData(T d),以及所述公共变量类ProducerData的取数据函数PopData()。所述写数据函数PushData(T d)将被生产者线程调用,用来向存储器中写入数据。
创建所述公共变量类ProducerData的取数据函数,所述取数据函数PopData()将被消费者线程调用,用来读取存储器中的数据。
S102,对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
本步骤中,公共变量类ProducerData建立好之后,对所述公共变量类进行实例化,获取线程本地存储TLS公共变量。
具体地,利用第一修饰函数ThreadStatic、及第二修饰函数static依次对所述公共变量类进行修饰,获取修饰实例;
将所述修饰实例赋值至所述TLS变量,形成所述TLS公共变量。
并将所述TLS公共变量存储至预先建立的消费者变量列表中,使得数据可以被消费者线程访问到。
S103,控制各生产者线程利用相应的所述TLS公共变量进行写数据;
本步骤中,控制各生产者线程利用相应的所述TLS公共变量进行写数据;具体地,调用TLS公共变量中的写数据函数PushData(T d)进行写数据。
所述写数据函数PushData(T d)的具体实现如下:
根据待写数据获取所述成员变量的数据类型标识flag;将所述数据类型标识分别与两个所述存储器的存储标识进行比较,确定目标存储器;所述目标存储器为存储标识与数据类型标识一致的存储器;
这里,每个存储器具有不同的存储标识,存储标识与所述数据类型标识相对应,因此需要根据数据类型标识来确定第一目标存储器。再利用写数据函数PushData(T d)将所述待写数据写入所述第一目标存储器中。
比如当数据类型标识为T时,就可以根据以下函数来确定存储器:
List<T>DataA,DataB
当DataA的存储标识与数据类型标识T一致时,就可以确定DataA为目标存储器,生产者线程就可以向DataA中写入数据。
这里,利用写数据函数将所述待写数据写入所述目标存储器中时,所述加锁临界变量对写数据过程进行加锁操作。需要说明的是,所述临界变量obj必须是共变量类ProducerData内的变量。
S104,控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据;
本步骤中,控制消费者者线程利用相应的所述TLS公共变量进行读取数据;具体地,调用TLS公共变量中的取数据函数PopData()进行读取数据。
首先,消费者线程修改数据的加锁,并将所述成员变量的数据类型标识进行翻转。其中,修改后的加锁只被当前消费者线程识别,避免在读取数据的过程中,其他消费者线程争抢数据资源。
而翻转成员变量的数据类型标识是为了使得当前周期的读写操作与下一周期的读写操作是在完全相反的存储器中进行,避免生产者线程发生堵塞。翻转的程序实现如下:
Lock(obj){flag=!flag}
比如,当前周期中,生产者线程在DataA中写数据,那么消费者线程则在DataB中读取数据;当成员变量的数据类型标识翻转后,下一周期中,生产者线程在DataB中写数据,那么消费者线程则在DataA中读取数据。这样,只要成员变量的数据类型标识翻转后,不管消费者线程有没有读取完毕,生产者线程就可以向另一存储器中进行写数据操作,也就是说,生产者线程至多等待一个翻转时间就可以实现写数据操作,降低了生产者线程的等待时间,从而避免了生产者线程阻塞,提高了程序的吞吐能力,进而提高了程序性能。
然后调用取数据函数PopData()进行读取数据,具体地,根据翻转后的成员变量的数据类型标识确定读取数据的第二目标存储器;再利用取数据函数PopData()从第二目标存储器中读取数据,其中,所述第二目标存储器为存储标识与翻转后的数据类型标识一致的存储器;所述第二目标存储器与所述第一目标存储器不同。
比如当数据类型标识为T时,就可以根据以下函数来确定存储器:
List<T>DataA,DataB
当DataB的存储标识与翻转后的数据类型标识一致时,就可以确定DataB为目标存储器,生产者线程就可以向DataB中写入数据。这样就避免同一个数据被同时读写。
当读取数据完毕之后,清空所述第二目标存储器。
实施例二
相应于实施例一,本实施例还提供一种避免线程阻塞的装置,如图2所示,所述装置包括:建立单元21、获取单元22、第一控制单元23及第二控制单元24;其中,
为了避免多个生产者线程需要在向同一个数据块进行写数据操作,需要等待,导致生产者线程堵塞,建立单元21需要为各生产者线程建立相应的公共变量类ProducerData,使得每个生产者线程都对应一个公共变量类ProducerData。
首先定义公共变量类ProducerData,所述公共变量类ProducerData包含两个存储器,可以为DataA和DataB;还包括成员变量bool flag及加锁临界变量Object obj;所述bool为一个数据类型,所述flag为数据类型标识,所述数据类型包括:True,简称T;及Flase,简称F。
然后,创建所述公共变量类ProducerData的写数据函数PushData(T d),以及所述公共变量类ProducerData的取数据函数PopData()。所述写数据函数PushData(T d)将被生产者线程调用,用来向存储器中写入数据。
创建所述公共变量类ProducerData的取数据函数,所述取数据函数PopData()将被消费者线程调用,用来读取存储器中的数据。
当公共变量类ProducerData建立好之后,获取单元22用于对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
具体地,所述获取单元22利用第一修饰函数ThreadStatic、及第二修饰函数static依次对所述公共变量类进行修饰,获取修饰实例;
将所述修饰实例赋值至所述TLS变量,形成所述TLS公共变量。
并将所述TLS公共变量存储至预先建立的消费者变量列表中,使得数据可以被消费者线程访问到。
当获取到TLS公共变量后,第一控制单元21用于控制各生产者线程利用相应的所述TLS公共变量进行写数据。
具体地,第一控制单元21调用TLS公共变量中的写数据函数PushData(T d)进行写数据。
所述写数据函数PushData(T d)的具体实现如下:
根据待写数据获取所述成员变量的数据类型标识flag;将所述数据类型标识分别与两个所述存储器的存储标识进行比较,确定目标存储器;所述目标存储器为存储标识与数据类型标识一致的存储器;
这里,每个存储器具有不同的存储标识,存储标识与所述数据类型标识相对应,因此需要根据数据类型标识来确定第一目标存储器。再利用写数据函数PushData(T d)将所述待写数据写入所述第一目标存储器中。
比如当数据类型标识为T时,就可以根据以下函数来确定存储器:
List<T>DataA,DataB
当DataA的存储标识与数据类型标识T一致时,就可以确定DataA为目标存储器,生产者线程就可以向DataA中写入数据。
这里,利用写数据函数将所述待写数据写入所述目标存储器中时,所述加锁临界变量对写数据过程进行加锁操作。需要说明的是,所述临界变量obj必须是共变量类ProducerData内的变量。
那么第二控制单元24用于控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据。
具体地,第二控制单元24调用TLS公共变量中的取数据函数PopData()进行读取数据。
首先,消费者线程修改数据的加锁,并将所述成员变量的数据类型标识进行翻转。其中,修改后的加锁只被当前消费者线程识别,避免在读取数据的过程中,其他消费者线程争抢数据资源。
而翻转成员变量的数据类型标识是为了使得当前周期的读写操作与下一周期的读写操作是在完全相反的存储器中进行,避免生产者线程发生堵塞。翻转的程序实现如下:
Lock(obj){flag=!flag}
比如,当前周期中,生产者线程在DataA中写数据,那么消费者线程则在DataB中读取数据;当成员变量的数据类型标识翻转后,下一周期中,生产者线程在DataB中写数据,那么消费者线程则在DataA中读取数据。这样,只要成员变量的数据类型标识翻转后,不管消费者线程有没有读取完毕,生产者线程就可以向另一存储器中进行写数据操作,也就是说,生产者线程至多等待一个翻转时间就可以实现写数据操作,降低了生产者线程的等待时间,从而避免了生产者线程阻塞,提高了程序的吞吐能力,进而提高了程序性能。
然后调用取数据函数PopData()进行读取数据,具体地,根据翻转后的成员变量的数据类型标识确定读取数据的第二目标存储器;再利用取数据函数 PopData()从第二目标存储器中读取数据,其中,所述第二目标存储器为存储标识与翻转后的数据类型标识一致的存储器;所述第二目标存储器与所述第一目标存储器不同。
比如当数据类型标识为T时,就可以根据以下函数来确定存储器:
List<T>DataA,DataB
当DataB的存储标识与翻转后的数据类型标识一致时,就可以确定DataB为目标存储器,生产者线程就可以向DataB中写入数据。这样就避免同一个数据被同时读写。
当读取数据完毕之后,清空所述第二目标存储器。
实施例三
本实施例还提供一种避免线程阻塞的计算机设备,如图3所示,所述计算机设备包括:射频(Radio Frequency,RF)电路310、存储器320、输入单元330、显示单元340、音频电路350、WiFi模块360、处理器370、以及电源380等部件。本领域技术人员可以理解,图3中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
下面结合图3对计算机设备的各个构成部件进行具体的介绍:
RF电路310可用于信号的接收和发送,特别地,将基站的下行信息接收后,给处理器370处理。通常,RF电路310包括但不限于至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。
存储器320可用于存储软件程序以及模块,处理器370通过运行存储在存储器320的软件程序以及模块,从而执行计算机设备的各种功能应用以及数据处理。存储器320可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据计算机设备的使用所创建的数据等。此外,存储器320可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元330可用于接收输入的数字或字符信息,以及产生与计算机设备的用户设置以及功能控制有关的键信号输入。具体地,输入单元330可包括键盘331以及其他输入设备332。键盘331,可收集用户在其上的输入操作,并根据预先设定的程式驱动相应的连接装置。键盘331采集到输出信息后再送给处理器370。除了键盘331,输入单元330还可以包括其他输入设备332。具体地,其他输入设备332可以包括但不限于触控面板、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元340可用于显示由用户输入的信息或提供给用户的信息以及计算机设备的各种菜单。显示单元340可包括显示面板341,可选的,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板341。进一步的,键盘331可覆盖显示面板341,当键盘331检测到在其上或附近的触摸操作后,传送给处理器370以确定触摸事件的类型,随后处理器370根据输入事件的类型在显示面板341上提供相应的视觉输出。虽然在图3中键盘331与显示面板341是作为两个独立的部件来实现计算机设备的输入和输入功能,但是在某些实施例中,可以将键盘331与显示面板341集成而实现计算机设备的输入和输出功能。
音频电路350、扬声器351,传声器352可提供用户与计算机设备之间的音频接口。音频电路350可将接收到的音频数据转换后的电信号,传输到扬声器351,由扬声器351转换为声音信号输出;
WiFi属于短距离无线传输技术,计算机设备通过WiFi模块360可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图3示出了WiFi模块360,但是可以理解的是,其并不属于计算机设备的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。
处理器370是计算机设备的控制中心,利用各种接口和线路连接整个计算机设备的各个部分,通过运行或执行存储在存储器320内的软件程序和/或模块,以及调用存储在存储器320内的数据,执行计算机设备的各种功能和处理数据,从而对计算机设备进行整体监控。可选的,处理器370可包括一个或多个处理单元;优选的,处理器370可集成应用处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等。
计算机设备还包括给各个部件供电的电源380(比如电源适配器),优选的,电源可以通过电源管理系统与处理器370逻辑相连。
本发明实施例提供的避免线程阻塞的方法、装置及计算机设备能带来的有益效果至少是:
本发明实施例提供一种避免线程阻塞的方法、装置及计算机设备,所述方法包括:为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;控制各生产者线程利用相应的所述TLS公共变量进行写数据;控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据;如此,为每个生产者线程建立一个公共变量类,这样就可保证始终只有两个线程发生互斥访问;而在发生互斥访问时,由于公共变量类中包含两个存储器,因此可以在两个存储器中分别进行 读写操作,这样生产者线程就无需等待消费者线程取数据完毕之后再进行写数据操作,进而避免了生产者线程阻塞,提高了程序的吞吐能力,进而提高了程序性能。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解, 可以在实践中使用微处理器或者数字信号处理器(DSP,Digital Signal Processing)来实现根据本发明实施例的网关、代理服务器、系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读存储介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供;该程序被处理器执行时实现以下步骤:为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;控制各生产者线程利用相应的所述TLS公共变量进行写数据;控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种避免线程阻塞的方法,其特征在于,所述方法包括:
    为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
    对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
    控制各生产者线程利用相应的所述TLS公共变量进行写数据;
    控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
  2. 如权利要求1所述的方法,其特征在于,所述公共变量类中还包括:成员变量及加锁临界变量。
  3. 如权利要求1所述的方法,其特征在于,所述为各生产者线程建立相应的公共变量类,包括:
    创建所述公共变量类的写数据函数;
    创建所述公共变量类的取数据函数。
  4. 如权利要求1所述的方法,其特征在于,所述对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,包括:
    利用第一修饰函数ThreadStatic及第二修饰函数static依次对所述公共变量类进行修饰,获取修饰实例;
    将所述修饰实例赋值至所述TLS变量,形成所述TLS公共变量。
  5. 如权利要求2所述的方法,其特征在于,所述控制各生产者线程利用相应的所述TLS公共变量进行写数据,包括:
    获取所述成员变量的数据类型标识;
    将所述数据类型标识分别与两个所述存储器的存储标识进行比较,确定第一目标存储器;所述第一目标存储器为存储标识与数据类型标识一致的存储器;
    利用写数据函数将待写数据写入所述第一目标存储器中。
  6. 如权利要求5所述的方法,其特征在于,所述利用写数据函数将所述待写数据写入所述目标存储器中时,利用所述加锁临界变量对写数据过程进行加锁操作。
  7. 如权利要求2所述的方法,其特征在于,所述控制消费者线程利用所述消费者变量列表中所述TLS公共变量进行读取数据,包括:
    对所述成员变量进行加锁,将所述成员变量的数据类型标识进行翻转;
    根据翻转后的成员变量的数据类型标识确定第二目标存储器,所述第二目 标存储器为存储标识与翻转后的数据类型标识一致的存储器;
    利用取数据函数从所述第二目标存储器中读取数据;其中,
    所述第二目标存储器与第一目标存储器不同。
  8. 一种避免线程阻塞的装置,其特征在于,所述装置包括:
    建立单元,用于为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
    获取单元,用于对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
    第一控制单元,用于控制各生产者线程利用相应的所述TLS公共变量进行写数据;
    第二控制单元,用于控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现以下步骤:
    为各生产者线程建立相应的公共变量类,所述公共变量类中包含两个存储器;
    对所述公共变量类进行实例化,获取线程本地存储TLS公共变量,并将所述TLS公共变量存储至预先建立的消费者变量列表中;
    控制各生产者线程利用相应的所述TLS公共变量进行写数据;
    控制消费者线程利用所述消费者变量列表中的所述TLS公共变量进行读取数据。
  10. 一种避免线程阻塞的计算机设备,其特征在于,包括:
    至少一个处理器;以及
    与所述处理器通信连接的至少一个存储器,其中,
    所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如权利要求1至7任一所述的方法。
PCT/CN2017/107783 2017-09-29 2017-10-26 一种避免线程阻塞的方法、装置及计算机设备 WO2019061619A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710911296.6A CN107741883B (zh) 2017-09-29 2017-09-29 一种避免线程阻塞的方法、装置及计算机设备
CN201710911296.6 2017-09-29

Publications (1)

Publication Number Publication Date
WO2019061619A1 true WO2019061619A1 (zh) 2019-04-04

Family

ID=61236432

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/107783 WO2019061619A1 (zh) 2017-09-29 2017-10-26 一种避免线程阻塞的方法、装置及计算机设备

Country Status (2)

Country Link
CN (1) CN107741883B (zh)
WO (1) WO2019061619A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096378B (zh) * 2019-04-29 2021-01-08 杭州涂鸦信息技术有限公司 一种线程间通信方法及相关装置
CN112463412A (zh) * 2020-12-11 2021-03-09 中国人寿保险股份有限公司 一种线程变量在线程切换过程中复制的方法及相关设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101631328A (zh) * 2009-08-14 2010-01-20 北京星网锐捷网络技术有限公司 一种对共享资源互斥访问的同步方法、装置和网络设备
CN101861568A (zh) * 2007-09-17 2010-10-13 通用电气公司 用于交换数据的方法和系统
CN102156630A (zh) * 2010-01-21 2011-08-17 微软公司 按线程按实例的数据存储
US20120331475A1 (en) * 2011-06-21 2012-12-27 Microsoft Corporation Dynamically allocated thread-local storage
CN104809027A (zh) * 2015-04-21 2015-07-29 浙江大学 一种基于无锁缓冲区的数据采集方法
US9223638B2 (en) * 2012-09-24 2015-12-29 Sap Se Lockless spin buffer

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7917759B2 (en) * 2007-03-30 2011-03-29 Symantec Corporation Identifying an application user as a source of database activity
CN102023844B (zh) * 2009-09-18 2014-04-09 深圳中微电科技有限公司 并行处理器及其线程处理方法
US9086909B2 (en) * 2011-05-17 2015-07-21 Oracle International Corporation System and method for supporting work sharing muxing in a cluster
CN103914265B (zh) * 2014-04-09 2016-11-23 江苏物联网研究发展中心 集群细粒度内存管理方法
CN106445656B (zh) * 2016-09-06 2019-10-11 北京邮电大学 一种实现线程本地存储的方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101861568A (zh) * 2007-09-17 2010-10-13 通用电气公司 用于交换数据的方法和系统
CN101631328A (zh) * 2009-08-14 2010-01-20 北京星网锐捷网络技术有限公司 一种对共享资源互斥访问的同步方法、装置和网络设备
CN102156630A (zh) * 2010-01-21 2011-08-17 微软公司 按线程按实例的数据存储
US20120331475A1 (en) * 2011-06-21 2012-12-27 Microsoft Corporation Dynamically allocated thread-local storage
US9223638B2 (en) * 2012-09-24 2015-12-29 Sap Se Lockless spin buffer
CN104809027A (zh) * 2015-04-21 2015-07-29 浙江大学 一种基于无锁缓冲区的数据采集方法

Also Published As

Publication number Publication date
CN107741883A (zh) 2018-02-27
CN107741883B (zh) 2018-10-23

Similar Documents

Publication Publication Date Title
US9733926B1 (en) Bridge to connect an extended development capability device to a target device
KR102191318B1 (ko) 전자 디바이스들 사이의 액티비티 계속
RU2689203C2 (ru) Гибкая схема для настройки языковой модели
US10187770B2 (en) Forwarding activity-related information from source electronic devices to companion electronic devices
CN105183675A (zh) 对usb设备的访问方法、装置、终端、服务器及系统
US20220150990A1 (en) Device binding method and apparatus, and electronic device
CN103176789A (zh) 一种实现开放平台功能扩展的方法及系统
US11437036B2 (en) Smart speaker wake-up method and device, smart speaker and storage medium
CN107958365B (zh) 物料信息变更方法、装置、存储介质及电子设备
CN104484223A (zh) 一种安卓系统应用关闭方法和装置
WO2019000723A1 (zh) 一种实现弹窗交互事件的方法、装置及计算机设备
US20230362244A1 (en) Application interface migration system and method, and related device
WO2019061619A1 (zh) 一种避免线程阻塞的方法、装置及计算机设备
CN110430253B (zh) 一种提供小说更新通知信息的方法与设备
EP3356959B1 (en) Streaming records from parallel batched database access
CN109992399A (zh) 资源管理方法、装置、移动终端及计算机可读存储介质
KR102097931B1 (ko) 소스 전자 디바이스로부터 동반 전자 디바이스로의 액티비티 관련 정보 포워드
CN110515662B (zh) 双系统设备的远程控制方法、系统、设备及可读存储介质
CN116760899A (zh) 基于Kafka的并发消费方法、装置、设备和介质
TW201814515A (zh) 基於場景的應用操作方法、裝置、終端設備和操作系統
CN110324692B (zh) 用于实现小窗播放视频的直播间处理方法及装置
CN107463524A (zh) 一种访问数据的方法及相关设备
CN106528188B (zh) 一种应用加速方法及装置
WO2019134288A1 (zh) 一种用于实现视图控制器的方法、装置及计算机设备
CN104156227B (zh) 调用底层库的方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17927798

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17927798

Country of ref document: EP

Kind code of ref document: A1