Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

A thread acquisition method and device

An acquisition method and thread technology, applied in the field of communication, can solve the problem of reducing the efficiency of acquiring threads, and achieve the effects of reducing resource contention, improving efficiency, and enhancing scalability and robustness.

Active Publication Date: 2019-11-08
ADVANCED NEW TECH CO LTD
View PDF7 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

But its disadvantage is that when threads are acquired concurrently through the thread pool, in order to ensure that the same thread will not be acquired by two tasks to be executed at the same time, it needs to be locked and queued to acquire threads, which will reduce the efficiency of acquiring threads

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A thread acquisition method and device
  • A thread acquisition method and device
  • A thread acquisition method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0058] Such as figure 1 As shown, it is a schematic flow chart of a thread acquisition method proposed in the embodiment of the present application. The method specifically includes the following steps:

[0059] Step S101, when the application server starts, divide the thread pool into multiple thread sets.

[0060] In a specific application scenario, in order to implement subsequent thread processing, after the thread set division in this step, the following processing is also included:

[0061] First, the minimum number of threads and the maximum number of threads are set for each of the divided thread sets.

[0062] According to the setting result, create threads with a minimum number of threads for each of the thread sets, and then initialize each of the thread sets including the threads with the minimum number of threads.

[0063] It should be noted that, in the above processing, the reason why only threads with the minimum number of threads are created in the embodimen...

Embodiment 2

[0097] In order to further elaborate the technical solution of the present application, the technical solution of the present application is described in combination with specific application scenarios, as follows figure 2 As shown, a thread acquisition method proposed in this embodiment is applied to an application server, and the method specifically includes the following steps:

[0098] Step S201, create a thread pool when the application server is started, the thread pool is composed of a plurality of thread sets, create threads with a minimum number of threads for each thread set, and then initialize each thread pool containing the threads with the minimum number of threads The collection of threads.

[0099] In the preferred embodiment of this application, when the application service starts, creating a thread pool composed of multiple thread sets is equivalent to dividing the original large thread set into several small thread sets. The thread collections form a threa...

Embodiment 3

[0126] Based on the same application idea as the implementation process of the above-mentioned thread acquisition method, a thread acquisition device is also provided in the embodiment of the present application, such as image 3 As shown, the equipment includes:

[0127] A thread management module 31, configured to divide the thread pool into multiple thread sets when the application server starts;

[0128] The positioning module 32 is used to determine the thread to which each user task to be executed belongs to in each thread set divided by the thread management module 31 when it is confirmed that the user task needs to obtain a thread from the thread pool to perform an operation gather;

[0129] A judging module 33, configured to judge whether there are idle threads in each thread set determined by the positioning module 32;

[0130] The processing module 34 is configured to return the idle thread to the user task to be executed belonging to the current thread set when t...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a thread obtaining method and device. By applying the technical scheme provided by the method and the device, the problem of low thread obtaining efficiency caused by the fact that it is required to perform locking for judging whether threads are idle or not and obtain the threads by queuing when the threads are concurrently obtained through a thread pool in the prior art is solved. According to the technical scheme provided by the method and the device, when an application obtains a thread execution operation in the thread pool, the locking does not need to be performed, so that the resource contention between tasks is reduced as far as possible, the efficiency of obtaining the task execution threads is improved, and the scalability and robustness of the application are enhanced.

Description

technical field [0001] The present application relates to the technical field of communications, and in particular to a thread acquisition method and a thread acquisition device. Background technique [0002] In an application based on object-oriented programming, creating and destroying objects is time-consuming, because creating an object requires obtaining memory resources or other more resources. [0003] For example, in an application based on Java programming technology, a JVM (JAVA Virtual Machine, JAVA virtual machine) will try to track each object so that garbage collection can be performed after the object is destroyed. Therefore, one way to improve the efficiency of service programs is to reduce the number of object creation and destruction as much as possible, especially the creation and destruction of some resource-intensive objects. How to use existing objects to serve is a key problem that needs to be solved, so the thread pool technology was born. [0004] ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): G06F9/48G06F9/50
Inventor 王世纪
Owner ADVANCED NEW TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products