Disclosure of Invention
The application aims to solve the technical problem of improving concurrency when a pooling technology is applied to multi-thread programming, and provides a resource processing method and device.
In a first aspect, an embodiment of the present application provides a resource processing method, where the method includes:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
Optionally, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
Optionally, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, before determining that the resource does not exist in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring the resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
Optionally, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
Optionally, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
Optionally, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a second aspect, an embodiment of the present application provides a resource processing apparatus, including:
an obtaining unit, configured to obtain resources from an exclusive resource pool corresponding to a first thread, where the exclusive resource pool corresponding to the first thread is used to provide resources for the first thread;
And the running unit is used for running the first thread by using the acquired resources.
Optionally, the apparatus further includes:
And the first determining unit is used for determining that the resources exist in the exclusive resource pool corresponding to the first thread before the resources are acquired from the exclusive resource pool corresponding to the first thread.
Optionally, the apparatus further includes:
the locking unit is used for locking the shared resource pool and acquiring the resources from the shared resource pool under the condition that the resources do not exist in the exclusive resource pool corresponding to the first thread, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, the apparatus further includes:
And the second determining unit is used for determining that the resources exist in the shared resource pool before the shared resource pool is locked and the resources are acquired from the shared resource pool.
Optionally, the apparatus further includes:
a creating unit, configured to create a resource for the first thread if it is determined that no resource exists in the shared resource pool;
The operation unit is used for:
And running the first thread by using the created resources.
Optionally, the apparatus further includes:
And the first releasing unit is used for releasing the acquired resources into the exclusive resource pool corresponding to the first thread if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold after the first thread is operated.
Optionally, the apparatus further includes:
And a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold after the operation of the first thread is finished, where:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a third aspect, embodiments of the present application provide a resource processing device including a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising instructions for:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
Optionally, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, before determining that the resource does not exist in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring the resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
Optionally, the operations further include:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
Optionally, the operations further include:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a fourth aspect, embodiments of the present application provide a computer-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the method of any of the first aspects above.
Compared with the prior art, the embodiment of the application has the following advantages:
The embodiment of the application provides a resource processing method, in the method, a shared resource pool is not shared by a plurality of threads as in the prior art, and if a first thread needs to be operated, resources can be acquired from the shared resource pool only under the condition that the shared resource pool is not locked by other threads, so that the first thread is operated. In the present application, each thread may have a corresponding exclusive resource pool, for example, a first thread may have an exclusive resource pool corresponding to the first thread, where the exclusive resource pool corresponding to the first thread is only used to provide resources for the first thread, but not for other threads. Because of this, other threads than the first thread do not acquire resources from the exclusive resource pool corresponding to the first thread, in other words, the exclusive resource pool corresponding to the first thread is not locked by other threads as in the shared resource pool in the conventional art. When the first thread needs to be operated, the resources can be directly obtained from the exclusive resource pool corresponding to the first thread, so that the first thread is operated by utilizing the obtained resources. Therefore, by utilizing the scheme of the embodiment of the application, concurrency can be improved.
Detailed Description
In order to make the present application better understood by those skilled in the art, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The inventors of the present application have found that pooling techniques can be applied to multithreaded programming. In one example, resources may be created in advance and placed into a shared resource pool. The shared resource pool may be used to provide resources for multiple threads. Currently, when a plurality of threads acquire resources from a shared resource pool, at most only one thread can use the resources in the resource pool at the same time. Specifically, when thread 1 needs to acquire a resource from a shared resource pool, thread 1 may first lock the shared resource pool (may also be referred to as "locking the shared resource Chi Jiasuo"), then acquire a resource from the shared resource pool to run thread 1, and after thread 1 finishes running, may release the resource into the shared resource pool, and then unlock the shared resource pool. When the shared resource pool is in a locked state, other threads cannot acquire resources from the shared resource pool. In other words, if the shared resource pool is locked by thread 1, thread 2 cannot acquire resources from the shared resource pool, and thread 2 must wait until thread 1 releases the lock on the shared resource pool to acquire resources from the shared resource pool to run thread 2. Because of this, multiple threads cannot run simultaneously, reducing concurrency.
In order to solve the above problems, the embodiment of the application provides a resource processing method and device.
Various non-limiting embodiments of the present application are described in detail below with reference to the attached drawing figures.
Exemplary method
Referring to fig. 1, the flow chart of a resource processing method according to an embodiment of the present application is shown.
The resource processing method provided by the embodiment of the application may be executed by a controller or a processor having a data processing function, or may be executed by a device including the controller or the processor, and the embodiment of the application is not particularly limited. Wherein the device comprising the controller or processor includes, but is not limited to, a terminal device and a server.
In this embodiment, the resource processing method shown in fig. 1 may include, for example, the following steps S101 to S102.
S101, acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread.
In the embodiment of the application, an exclusive resource pool can be respectively created for each thread in the initialization stage of the service. Wherein a service may comprise one or more businesses that may run in a particular thread.
The first thread is any one of the threads. The exclusive resource pool corresponding to the first thread is only used for providing resources for the first thread, and not providing resources for other threads. In the embodiment of the present application, the resources in the exclusive resource pool corresponding to the first thread may include one or more of a thread pool, a memory pool, and a connection pool, for example. The thread pool, memory pool, and connection pool are not described in detail herein.
In the embodiment of the application, when the first thread is needed to be utilized to run the service, the resources can be obtained from the exclusive resource pool corresponding to the first thread.
S102, running the first thread by using the acquired resources.
After obtaining the resources from the exclusive resource pool corresponding to the first thread, the first thread can be operated by using the resources obtained from the exclusive resource pool corresponding to the first thread, so as to realize the processing of a certain service.
It will be appreciated from the above description that, due to the exclusive resource pool corresponding to the first thread, only resources are provided for the first thread, and resources are not provided for other threads. Thus, other threads, except the first thread, do not acquire resources from the exclusive resource pool corresponding to the first thread, in other words, the exclusive resource pool corresponding to the first thread is not locked by other threads as in the conventional shared resource pool. When the first thread needs to be operated, the resources can be directly obtained from the exclusive resource pool corresponding to the first thread, so that the first thread is operated by utilizing the obtained resources. Therefore, by utilizing the scheme of the embodiment of the application, concurrency can be improved.
In some scenarios, after the traffic processing is completed, the resources used to process the traffic may be released. During the service processing, there may be multi-thread scheduling, which may cause the resources acquired from the exclusive resource pool of the first thread to be released to the exclusive resource pool of other threads, for example, the second thread, so that the resources in the exclusive resource pool corresponding to the first thread are less and less, and even no resources are available. And the resources in the exclusive resource pool corresponding to the second thread are more and more.
For example, for user login traffic, thread 1, which involves applying a link to verify if the username and password match, and thread 2, which returns the link. When the thread 1 is operated, resources are acquired from an exclusive resource pool corresponding to the thread 1, and the thread operated in a return link is the thread 2, so when the user name and the password are verified to be matched, the resources acquired from the exclusive resource pool of the thread 1 are released to the exclusive resource pool corresponding to the thread 2 when the link is further returned, so that the resources in the exclusive resource pool corresponding to the thread 1 are reduced, and the resources in the exclusive resource pool corresponding to the thread 2 are increased.
Because no resources may be available in the exclusive resource pool corresponding to the first thread as described above, in an example of the embodiment of the present application, it may be further determined whether resources exist in the exclusive resource pool corresponding to the first thread before executing the foregoing S101, and if it is determined that resources exist in the exclusive resource pool corresponding to the first thread, the foregoing S101 and subsequent steps are executed again, so as to implement running the first thread using the resources in the exclusive resource pool of the first thread.
In addition, in order to make the first thread normally run even if there is no resource in the exclusive resource pool corresponding to the first thread. In the embodiment of the application, in addition to creating an exclusive resource pool for each thread, a shared resource pool may be created in the initialization stage of the service, where the shared resource pool is used to provide resources for a plurality of threads, and the plurality of threads includes the first thread. In this way, when there is no resource in the exclusive resource pool corresponding to the first thread, the resource may be acquired from the shared resource pool, and the first thread may be executed using the resource acquired from the shared resource pool. Specifically, before resources are acquired from the shared resource pool, the shared resource pool may be locked first, and then resources are acquired from the shared resource pool.
In some scenarios of embodiments of the present application, there are resources in the shared resource pool during the initialization phase of the service. However, as the service runs, resources may or may not still exist in the shared resource pool. For specific reasons reference is made to the description of the resource release section below, which is not explained in detail here. Therefore, in one implementation manner of the embodiment of the present application, before locking the shared resource pool, it may also be determined whether a resource exists in the shared resource pool, and if it is determined that a resource exists in the shared resource pool, the shared resource pool is locked again, and a resource is acquired from the shared resource pool to run the first thread.
In an example of the embodiment of the present application, if no resource exists in the exclusive resource pool corresponding to the first thread and no resource is included in the shared resource pool, a new resource may be created for the first thread, and the first thread is operated by using the created resource, so that the first thread can operate normally.
In the embodiment of the present application, after the first thread is run, the resources used for running the first thread may be released, that is, the acquired resources mentioned in S102 may be released. In some embodiments, considering that if there is a resource in the exclusive resource pool corresponding to the first thread, concurrency may be improved to the greatest extent, so that when the first thread needs to be run, the resource needs to be acquired from the shared resource pool or re-created, and therefore, after the first thread is run, the resource used for running the first thread may be released to the exclusive resource pool corresponding to the first thread.
It will be appreciated that the resources used by the first thread to run as referred to herein may be obtained from an exclusive resource pool to which the first thread corresponds, may be obtained from a shared resource pool, or may be temporarily created for the first thread. The embodiment of the present application is not particularly limited. Also, even if the resource used for running the first thread is obtained from the shared resource pool, the resource may be released to the exclusive resource pool corresponding to the first thread, so that, with the running of the service, there may be no resource in the shared resource pool.
In other embodiments, it is contemplated that the resources required to run the first thread are typically limited, e.g., do not exceed a first threshold. Therefore, when the original resources in the exclusive resource pool of the first thread have exceeded the first threshold, it is indicated that there are enough resources in the exclusive resource pool corresponding to the first thread to run the first thread, and in this case, in the embodiment of the present application, the resources used for running the first thread may be released to the shared resource pool, so that the shared resource pool may provide resources for other threads, and the problem that the overall resource utilization is low due to too many resources in the resource pool corresponding to the first thread may also be avoided. Specifically, the shared resource pool may be locked, and after the resources used by the first thread are released to the shared resource pool, the shared resource pool may be unlocked.
In other words, in the embodiment of the present application, after the operation of the first thread is finished, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to the first threshold, the resources used for operating the first thread are released to the exclusive resource pool corresponding to the first thread, so as to improve concurrency to the greatest extent. After the first thread finishes running, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool, and releasing the acquired resources into the shared resource pool, so that the shared resource pool can provide resources for other threads.
Exemplary apparatus
Based on the method provided by the above embodiment, the embodiment of the present application further provides a resource processing device, and the device is described below with reference to the accompanying drawings.
Referring to fig. 2, the structure of a resource processing device according to an embodiment of the present application is shown. The apparatus 200 may specifically comprise, for example, an acquisition unit 201 and an operation unit 202.
An obtaining unit 201, configured to obtain a resource from an exclusive resource pool corresponding to a first thread, where the exclusive resource pool corresponding to the first thread is used to provide the resource for the first thread;
And the running unit 202 is configured to run the first thread by using the acquired resource.
In one implementation, the apparatus further comprises:
And the first determining unit is used for determining that the resources exist in the exclusive resource pool corresponding to the first thread before the resources are acquired from the exclusive resource pool corresponding to the first thread.
In one implementation, the apparatus further comprises:
the locking unit is used for locking the shared resource pool and acquiring the resources from the shared resource pool under the condition that the resources do not exist in the exclusive resource pool corresponding to the first thread, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, the apparatus further comprises:
And the second determining unit is used for determining that the resources exist in the shared resource pool before the shared resource pool is locked and the resources are acquired from the shared resource pool.
In one implementation, the apparatus further comprises:
a creating unit, configured to create a resource for the first thread if it is determined that no resource exists in the shared resource pool;
The operation unit 202 is configured to:
And running the first thread by using the created resources.
In one implementation, the apparatus further comprises:
And the first releasing unit is used for releasing the acquired resources into the exclusive resource pool corresponding to the first thread if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold after the first thread is operated.
In one implementation, the apparatus further comprises:
And a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold after the operation of the first thread is finished, where:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
Since the apparatus 200 is an apparatus corresponding to the method provided in the above method embodiment, the specific implementation of each unit of the apparatus 200 is the same as the above method embodiment, and therefore, with respect to the specific implementation of each unit of the apparatus 200, reference may be made to the description part of the above method embodiment, and details are not repeated herein.
The method provided by the embodiment of the application can be executed by the client or the server, and the client and the server for executing the method are respectively described below.
Fig. 3 shows a block diagram of a client 300. For example, the client 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to FIG. 3, a client 300 may include one or more of a processing component 302, a memory 304, a power supply component 306, a multimedia component 308, an audio component 310, an input/output (I/O) interface 33, a sensor component 314, and a communication component 316.
The processing component 302 generally controls overall operation of the client 300, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing element 302 may include one or more processors 320 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 302 can include one or more modules that facilitate interactions between the processing component 302 and other components. For example, the processing component 302 may include a multimedia module to facilitate interaction between the multimedia component 308 and the processing component 302.
Memory 304 is configured to store various types of data to support operations at client 300. Examples of such data include instructions for any application or method operating on client 300, contact data, phonebook data, messages, pictures, video, and the like. The memory 304 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 306 provides power to the various components of the client 300. The power components 306 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the client 300.
The multimedia component 308 includes a screen between the client 300 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 308 includes a front-facing camera and/or a rear-facing camera. When the client 300 is in an operation mode, such as a photographing mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 310 is configured to output and/or input audio signals. For example, the audio component 310 includes a Microphone (MIC) configured to receive external audio signals when the client 300 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 304 or transmitted via the communication component 316. In some embodiments, audio component 310 further comprises a speaker for outputting audio signals.
The I/O interface provides an interface between the processing component 302 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, a home button, a volume button, an activate button, and a lock button.
The sensor assembly 314 includes one or more sensors for providing status assessment of various aspects for the client 300. For example, the sensor assembly 314 may detect an on/off state of the device 300, a relative positioning of the components, such as a display and keypad of the client 300, the sensor assembly 314 may also detect a change in position of the client 300 or a component of the client 300, the presence or absence of user contact with the client 300, the orientation or acceleration/deceleration of the client 300, and a change in temperature of the client 300. The sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. The sensor assembly 314 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 314 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 316 is configured to facilitate communication between the client 300 and other devices, either wired or wireless. The client 300 may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication part 316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 316 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the client 300 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for performing the following methods:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
In one implementation, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, before determining that no resource exists in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring a resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
In one implementation, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
In one implementation, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
Fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application. The server 400 may vary considerably in configuration or performance and may include one or more central processing units (central processing units, CPUs) 422 (e.g., one or more processors) and memory 432, one or more storage mediums 430 (e.g., one or more mass storage devices) that store applications 442 or data 444. Wherein memory 432 and storage medium 430 may be transitory or persistent storage. The program stored on the storage medium 430 may include one or more modules (not shown), each of which may include a series of instruction operations on a server. Still further, the central processor 422 may be configured to communicate with the storage medium 430 and execute a series of instruction operations in the storage medium 430 on the server 400.
Still further, the central processor 422 may perform the following method:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
In one implementation, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, before determining that no resource exists in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring a resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
In one implementation, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
In one implementation, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
The server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input/output interfaces 456, one or more keyboards 456, and/or one or more operating systems 441, such as Windows ServerTM, mac OS XTM, unixTM, linuxTM, freeBSDTM, and the like.
Embodiments of the present application also provide a computer readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the resource processing method provided by the above method embodiments.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims
The foregoing description of the preferred embodiments of the application is not intended to limit the application to the precise form disclosed, and any such modifications, equivalents, and alternatives falling within the spirit and scope of the application are intended to be included within the scope of the application.