CN109246470B - Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium - Google Patents

Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium Download PDF

Info

Publication number
CN109246470B
CN109246470B CN201811151399.8A CN201811151399A CN109246470B CN 109246470 B CN109246470 B CN 109246470B CN 201811151399 A CN201811151399 A CN 201811151399A CN 109246470 B CN109246470 B CN 109246470B
Authority
CN
China
Prior art keywords
bullet screen
message
current
thread
distribution
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201811151399.8A
Other languages
Chinese (zh)
Other versions
CN109246470A (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201811151399.8A priority Critical patent/CN109246470B/en
Publication of CN109246470A publication Critical patent/CN109246470A/en
Application granted granted Critical
Publication of CN109246470B publication Critical patent/CN109246470B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/435Processing of additional data, e.g. decrypting of additional data, reconstructing software from modules extracted from the transport stream
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/478Supplemental services, e.g. displaying phone caller identification, shopping application
    • H04N21/4788Supplemental services, e.g. displaying phone caller identification, shopping application communicating with other users, e.g. chatting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/488Data services, e.g. news ticker
    • H04N21/4884Data services, e.g. news ticker for displaying subtitles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a storage medium for multithread synchronous bullet screen distribution. The method comprises the following steps: when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed with the current concurrency number from the message set, and determining the distribution threads with the current concurrency number; determining bullet screen messages with sequence relevance in all bullet screen messages to be distributed as associated bullet screen messages, and determining distribution threads corresponding to all the associated bullet screen messages as associated threads; based on a bullet screen message distribution mechanism, distributing each associated bullet screen message by using each associated thread in an associated manner, and distributing each residual bullet screen message in each bullet screen message to be distributed in parallel by using each residual thread in each distribution thread. Through the technical scheme, the bullet screen messages are sequentially and efficiently distributed, and the distribution timeliness and the distribution accuracy of the bullet screen messages are improved.

Description

Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to an information communication technology, in particular to a multi-thread synchronous bullet screen distribution method, a device, equipment and a storage medium.
Background
Barrage messages are heavily used in audio/video playing/live broadcasting application software. Generally, a bullet screen message is sent to application software by a server (i.e., a bullet screen server) for transmitting and processing the bullet screen message, and then a bullet screen distributing module having a function of distributing the bullet screen message in the application software distributes the received bullet screen message to each bullet screen receiving module that needs to receive the bullet screen message.
When the number of bullet screen messages sent by the bullet screen server is large and the bullet screen distribution module cannot distribute the bullet screen messages in time, a message set is usually established in the bullet screen distribution module to store the undistributed bullet screen messages.
However, in the existing bullet screen message distribution mode, the bullet screen distribution module acquires the cached bullet screen messages from the message cache set one by one according to the sequence of issuing the bullet screen messages by the bullet screen server and distributes the bullet screen messages, which may cause low distribution efficiency of the bullet screen distribution module and reduce distribution timeliness of the bullet screen messages.
Disclosure of Invention
The embodiment of the invention provides a multi-thread synchronous bullet screen distribution method, a device, equipment and a storage medium, which are used for realizing sequential and efficient bullet screen message distribution and improving the distribution timeliness and distribution accuracy of bullet screen messages.
In a first aspect, an embodiment of the present invention provides a multi-thread synchronized bullet screen distribution method, including:
when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed in the current concurrency number from a message set, and determining the distribution threads in the current concurrency number;
determining bullet screen messages with sequence relevance in the bullet screen messages to be distributed as associated bullet screen messages, and determining distribution threads corresponding to the associated bullet screen messages as associated threads;
based on a bullet screen message distribution mechanism, distributing the associated bullet screen messages by using the associated thread associations, and distributing the remaining bullet screen messages in the bullet screen messages to be distributed in parallel by using the remaining threads in the distribution threads.
In a second aspect, an embodiment of the present invention further provides a multi-thread synchronous bullet screen dispensing apparatus, where the apparatus includes:
the concurrent bullet screen and thread determining module is used for determining the current concurrency quantity of bullet screen messages according to the current system state parameter values when the multithreading bullet screen distribution condition is met, acquiring the bullet screen messages to be distributed in the current concurrency quantity from a message set, and determining the distribution threads in the current concurrency quantity;
the associated bullet screen and thread determining module is used for determining bullet screen messages with sequence association in the bullet screen messages to be distributed as associated bullet screen messages and determining the distribution threads corresponding to the associated bullet screen messages as associated threads;
and the bullet screen message distribution module is used for distributing the associated bullet screen messages in an associated manner by using the associated threads based on a bullet screen message distribution mechanism, and distributing the remaining bullet screen messages in the bullet screen messages to be distributed in parallel by using the remaining threads in the distribution threads.
In a third aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the bullet screen distribution method with multi-thread synchronization provided by any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the multi-thread synchronized bullet screen distribution method provided in any embodiment of the present invention.
According to the method and the device, when the multithreading bullet screen message distribution condition is met, the number of bullet screen messages distributed in parallel is determined according to the current system state parameter values, so that the blocking degree of the bullet screen message parallel distribution process caused by busy system is effectively reduced on the basis of improving the bullet screen message distribution efficiency by utilizing the bullet screen message parallel distribution technology, and the bullet screen message distribution efficiency and the bullet screen message distribution timeliness are further improved. By determining the associated bullet screen messages and the associated threads and distributing the associated bullet screen messages by utilizing the associated thread association, the distribution sequence of the bullet screen messages in the multithreading bullet screen distribution process is ensured, and the distribution accuracy of the bullet screen messages is improved on the basis of improving the bullet screen message distribution efficiency.
Drawings
Fig. 1 is a flowchart of a multi-thread synchronous bullet screen distribution method according to a first embodiment of the present invention;
fig. 2 is a flowchart of a multi-thread synchronous bullet screen distribution method in the second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a multi-thread synchronous bullet screen dispensing apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
The bullet screen message distribution method based on the multithread synchronization provided by the embodiment can be suitable for bullet screen message distribution in audio and video playing/live broadcast application software in an Android client, and is particularly suitable for the situation that the number of bullet screen messages is large, and one bullet screen message is sent to at least one bullet screen receiving object. The method can be executed by a multi-thread synchronous bullet screen distribution device, the device can be realized in a software and/or hardware mode, and the device can be integrated in equipment with a bullet screen message distribution function, which carries an Android system, for example, typical user terminal equipment such as a mobile phone, a tablet personal computer or a smart television is provided. The execution main body in this embodiment is a bullet screen distribution object, which is an instantiation object of a bullet screen distribution class defined in a bullet screen distribution module and used for realizing a bullet screen distribution function. Referring to fig. 1, the method of the present embodiment specifically includes the following steps:
s110, when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed in the current concurrency number from the message set, and determining the distribution threads in the current concurrency number.
The multithreading bullet screen distribution condition refers to a preset condition for triggering multithreading parallel distribution of bullet screen messages, and may be, for example, reception of a new bullet screen message, a bullet screen message distribution progress, setting of a timer, and the like. The system state parameter refers to a parameter capable of representing the operation state of the system. The current system state parameter value refers to a value of the system state parameter at the current time. Illustratively, the current system state parameters include at least one of a current CPU occupancy, a current memory occupancy, and a current system temperature. In specific implementation, at least one of the current CPU occupancy rate, the current memory occupancy rate, and the current system temperature may be used to represent the operating state of the device equipped with the Android system. The advantage of this arrangement is that the busyness of the current system can be reflected from at least one perspective.
The current concurrency number refers to the number of barrage messages which are distributed in parallel at the current moment. The message set refers to a set for storing the bullet screen messages in the bullet screen distribution object, and the data structure of the message set can be an array, a list or a queue. In order to better ensure the storage order and the acquisition order of the bullet screen messages, the message set is preferably a queue structure with a first-in first-out characteristic. In the embodiment of the invention, in order to realize the parallel distribution of the bullet screen messages, when receiving the bullet screen messages sent by the bullet screen server, the bullet screen distribution objects do not immediately distribute the bullet screen messages, but store the bullet screen messages in the message set. The bullet screen message to be distributed refers to a bullet screen message to be distributed in the operation. The distribution thread is a thread which is required to be specially used for bullet screen message distribution in the operation.
Specifically, the bullet screen distribution object first determines whether a multithreading bullet screen distribution condition is satisfied, for example, determines whether it receives a new bullet screen message sent by the bullet screen server, or determines whether it has finished distributing the previous bullet screen message, or determines whether a timing cycle of a set timer has reached. If the judgment result is yes, the bullet screen distribution object can acquire the current system state parameter value, which indicates that the multithreading bullet screen distribution condition is met. If the current system state parameter value is higher, the current power consumption of the system is higher, and the system cannot bear excessive parallel barrage message distribution tasks, and at the moment, the current concurrency quantity can be set to be a smaller numerical value; otherwise, the current available resources of the system are rich, and the current concurrency number can be set to be a larger value.
In this embodiment, the corresponding relationship between the system state parameter value and the concurrency number of the bullet screen message may be set as a lookup table with discrete values, so as to store each value range of the system state parameter value and the concurrency number corresponding to each value range. Then, the process of determining the current concurrency number of the bullet screen message according to the current system state parameter value is as follows: and determining a value range corresponding to the current system state parameter value according to the current system state parameter value, and then determining the concurrency number corresponding to the value range in the lookup table as the current concurrency number. The advantage of setting up like this is that the speed of confirming of present concurrent number is fast, can further improve the distribution efficiency of barrage message.
In this embodiment, the correspondence between the system state parameter value and the concurrency number of the bullet screen message may also be set as a numerical calculation formula, the system state parameter value is set as a dependent variable, and the concurrency number is set as a dependent variable. And then, the corresponding current concurrency number can be obtained by directly calculating according to the current system state parameter value. The method has the advantages that the current concurrency number can be determined more accurately, so that more appropriate number of concurrent threads can be determined subsequently, the thread blocking situation can be further reduced, and the bullet screen message distribution efficiency can be further improved.
After the operation, the bullet screen distributing object obtains the bullet screen messages of the current concurrency quantity in sequence from the message set to serve as bullet screen messages to be distributed. In addition, the bullet screen distribution object acquires the current concurrent number of threads from a thread pool which dynamically manages all threads in the system, and the threads are used as distribution threads. And then, distributing a distribution thread for each bullet screen message to be distributed, wherein in the distribution process, it needs to be ensured that one bullet screen message to be distributed corresponds to one distribution thread, and the bullet screen messages to be distributed corresponding to each distribution thread are not repeated. Each bullet screen message to be distributed can be distributed by each distribution thread. It should be noted that, in this step, the operation of determining the bullet screen message to be distributed and the operation of determining the distribution thread are not limited by the execution order, and the two operations may be executed sequentially or synchronously.
S120, determining bullet screen messages with sequence relevance in the bullet screen messages to be distributed as related bullet screen messages, and determining distribution threads corresponding to the related bullet screen messages as related threads.
The sequence relevance refers to a relevance relationship between the bullet screen messages in a sequence, for example, if the processing of one bullet screen message needs to depend on the processing result of the other bullet screen message, the two bullet screen messages can be determined as bullet screen messages with sequence relevance (i.e., relevant bullet screen messages). The associated thread refers to a thread having order relevance among barrage messages distributed in a plurality of threads.
Specifically, the bullet screen distribution object determines the sequence relevance between the bullet screen messages to be distributed by analyzing the information of the bullet screen messages to be distributed acquired in S110, so that each bullet screen message to be distributed with the sequence relevance is determined as a relevant bullet screen message. For example, the association identifier of the sequential association message carried in each bullet screen message to be distributed may be analyzed, and both the bullet screen message to be distributed and the bullet screen message to be distributed corresponding to the association identifier thereof are determined as the association bullet screen message, and the association identifier may be determined in the bullet screen server or the bullet screen distribution object according to the dependency between the bullet screen messages; or analyzing the bullet screen receiving object corresponding to each bullet screen message to be distributed, and determining all bullet screen messages to be distributed with the same bullet screen receiving object as the associated bullet screen messages. Here, the bullet screen receiving object refers to a component object that needs to receive the bullet screen message in the bullet screen receiving module, and may be, for example, a view object for displaying the bullet screen message, a service controller object for performing data processing on the bullet screen message, or a data manager object for storing or transmitting the bullet screen message.
And then, the bullet screen distribution object determines the distribution thread distributed by each associated bullet screen message as an associated thread so as to control the running sequence among the associated threads in the following process.
And S130, distributing each associated bullet screen message by using each associated thread association based on a bullet screen message distribution mechanism, and distributing each residual bullet screen message in each bullet screen message to be distributed in parallel by using each residual thread in each distribution thread.
The bullet screen message distribution mechanism is an implementation mechanism for distributing bullet screen messages from bullet screen distribution objects to bullet screen receiving objects. For example, when the bullet screen message distribution object and the bullet screen receiving object are in the same functional module, the bullet screen message distribution mechanism may be the bullet screen message distribution through direct object reference between the two. When the bullet screen distributing object and the bullet screen receiving object are in different functional modules, the bullet screen message distributing mechanism can establish a coupled communication channel between the bullet screen distributing object and the bullet screen receiving object through an inter-module interaction interface provided by the different functional modules, and the bullet screen distributing object directly distributes bullet screen messages to the corresponding bullet screen receiving object through the coupled communication channel; or a bridge communication channel between the bullet screen distribution object and the bullet screen receiving object is established through a communication protocol of a user-defined interface type, and the bullet screen distribution object directly distributes bullet screen information to the corresponding bullet screen receiving object through the bridge communication channel; the transmission of the barrage message can also be performed through a system communication channel in the Android system, such as a system broadcast channel or a third-party open source event bus EventBus. The remaining threads refer to the other dispatch threads except the respective associated threads in all dispatch threads. The remaining bullet screen messages refer to other bullet screen messages to be distributed except for the associated bullet screen messages in all the bullet screen messages to be distributed.
Specifically, all the remaining bullet screen messages can be independently distributed in parallel because the remaining bullet screen messages have no correlation. And the bullet screen distributing object distributes all the residual bullet screen messages in parallel by utilizing all the residual threads based on a bullet screen message distributing mechanism.
Since each associated bullet screen message has a sequence association, in order to ensure the sequence of bullet screen message distribution and avoid the confusion of bullet screen message processing logic execution in bullet screen receiving objects, in this embodiment, it is necessary to ensure the sequence distribution of each associated bullet screen message. For example, the associative distribution process may be strict sequential distribution (i.e., full sequential distribution) of all associated bullet screen messages, and each associated thread needs to run serially according to the message ordering of the associated bullet screen messages. The benefit of this arrangement is to simplify the bullet screen associative dispensing logic. The message ordering here refers to the arrangement order of the bullet screen messages, which may be the order of the bullet screen messages issued by the bullet screen server, or the storage order of the bullet screen messages in the message set. The associative distribution process can also be partial sequential distribution with direct association in two associative barrage messages at adjacent positions in the message ordering, and the other non-associative parts are distributed in parallel. The advantage of setting up like this is that further improves the distribution efficiency and the distribution timeliness of barrage message to a certain extent. Here, the bullet screen message distribution process in each associated thread also follows the bullet screen message distribution mechanism.
Illustratively, the associatively distributing each associated bullet screen message by each associated thread comprises the following steps: A. according to the message sequence of each associated barrage message, taking the first associated barrage message as the current barrage message, and taking the associated thread corresponding to the current barrage message as the current associated thread; B. distributing the current barrage message by using the current associated thread, and sending a thread starting message to a next associated thread corresponding to the next associated barrage message through the current associated thread based on a pre-constructed thread communication channel when the current barrage message is not the last associated barrage message so as to trigger the operation of the next associated thread; C. and updating the current barrage message into a next associated barrage message, updating the current associated thread into a next associated thread, and returning to execute the operation of distributing the current barrage message by using the current associated thread.
The thread communication channel refers to a channel which is constructed in advance and is used for communication among different threads. The thread start message refers to a message for triggering the thread to run, and may be a preset message for indicating the thread to run, such as an identifier composed of at least one of numbers, letters and special symbols, or a notification message carrying information such as the distribution thread and the bullet screen message to be distributed.
In this embodiment, the operation of other associated threads except the first associated thread is set as a message triggered operation mechanism, and only after one associated thread receives a thread start message, it will change from the waiting state to the awake state and perform a dispatch operation. In addition, the thread communication channel in this embodiment is constructed in the form of an interface protocol, and the construction timing is after each associated thread is determined. Taking two threads as an example, the construction process of the thread communication channel is as follows: the second associated thread inherits the predefined thread communication interface protocol and rewrites the thread communication function, wherein the thread communication function is a callback function, and the function input parameter of the callback function is a thread starting message. At this time, the second associated thread has inter-thread communication function and includes the inter-thread communication function. And then, registering a second associated thread after inheriting the interface protocol to the first associated thread so that the first associated thread holds the reference relation of the second associated thread. In this way, the first associated thread may send messages to the second associated thread.
Specifically, as is apparent from the above description, the relational distribution process includes sequential distribution and is the same every time the distribution process is performed, so the relational distribution process is set to one cycle process to simplify the program development process. In specific implementation, the bullet screen distribution object firstly sorts the associated bullet screen messages according to the message sequence of the associated bullet screen messages, takes the first associated bullet screen message as the current bullet screen message, and takes the associated thread corresponding to the current bullet screen message as the current associated thread. It is understood that both the current bullet screen message and the current associated thread are loop variables in the loop process. Then, the current associated thread is used to distribute the current barrage message, and the distribution process should correspond to the two cases of the total sequential distribution and the partial sequential distribution described in S130.
And after the current barrage message is distributed, judging whether the current barrage message is the last associated barrage message. If yes, indicating that all the associated barrage messages are distributed completely, and ending the cycle process. If not, taking the thread starting message as a function input parameter, calling a thread communication function through the current associated thread, and sending the thread starting message to the next associated thread. And the next associated thread gets the thread start message by calling back the thread communication function. At this time, the bullet screen distribution object detects the thread starting message, and then uses the next associated bullet screen message as a new current bullet screen message and uses the associated thread corresponding to the next associated bullet screen message as a new current associated thread according to the message sequencing, so as to realize the updating operation of the current bullet screen message and the current associated thread, and return to execute the operation of the step B, thereby forming a cycle process of distributing the associated bullet screen message.
According to the technical scheme of the embodiment, when the multithreading bullet screen message distribution condition is met, the number of bullet screen messages distributed in parallel is determined according to the current system state parameter value, so that the blocking degree of the bullet screen message parallel distribution process caused by busy system is effectively reduced on the basis of improving the bullet screen message distribution efficiency by utilizing the bullet screen message parallel distribution technology, and the bullet screen message distribution efficiency and the bullet screen message distribution timeliness are further improved. By determining the associated bullet screen messages and the associated threads and distributing the associated bullet screen messages by utilizing the associated thread association, the distribution sequence of the bullet screen messages in the multithreading bullet screen distribution process is ensured, and the distribution accuracy of the bullet screen messages is improved on the basis of improving the bullet screen message distribution efficiency.
On the basis of the technical scheme, the bullet screen message distribution mechanism comprises: acquiring a target bullet screen receiving object corresponding to the message identifier from the reference object set according to the message identifier of the bullet screen message; converting a target bullet screen receiving object into an object of a bullet screen distribution protocol type as a target receiving object according to a bullet screen distribution protocol; and taking the bullet screen message as a function input parameter, calling a bullet screen distribution function through the target receiving object, and distributing the bullet screen message to the target receiving object.
The reference object set is a set for storing reference relations of all bullet screen receiving objects and is arranged in bullet screen distribution objects. In order to obtain the required bullet screen receiving object from the reference object set, an index item for searching a set element, such as a message identifier of a bullet screen message and/or a hash value of the bullet screen receiving object, may also be stored in the reference object set.
Illustratively, the object collection stores a bullet screen receiving object that inherits a predefined bullet screen distribution protocol. The bullet screen distribution protocol refers to an inter-component communication protocol followed by bullet screen distribution objects when bullet screen distribution is performed, and the bullet screen distribution protocol comprises a bullet screen distribution function for realizing bullet screen message distribution. The bullet screen distribution protocol is an interface type protocol with public authority identifier public. For example, the bullet delivery protocol IMessage may be defined as: public interface information { public void onMessage (String type, Message msg); }. In the protocol definition, the bullet screen distribution function onMessage has two function input parameters, which are a Message identifier of a String type and a Message body of a Message type for bearing bullet screen messages. The function input parameters of the function can be adaptively adjusted according to the actual application requirements.
In this embodiment, the bullet screen distribution object and the bullet screen receiving object are in different functional modules, so the bullet screen message distribution mechanism is set to establish a bridge communication channel between the bullet screen distribution object and the bullet screen receiving object. In specific implementation, an application object set of a global scope and a bullet screen distribution protocol including a bullet screen distribution function are predefined. The bullet screen receiving class inherits the bullet screen distribution protocol through an interface protocol in the Java language inherits the keyword instance and realizes a bullet screen distribution function in the bullet screen receiving class. Then, when each bullet screen receiving object is created, each bullet screen receiving object is generated by calling the constructor instantiation of the bullet screen receiving class, and the bullet screen receiving object is also a protocol receiving object and contains a bullet screen distribution function OnMessage as a callback function. After each bullet screen receiving object is created, the bullet screen receiving objects are stored in the reference object set, so that the bullet screen distributing object can hold the reference relation of each bullet screen receiving object through the reference object set, and the bridge type communication channel is constructed.
Specifically, each bullet screen receiving object is pre-stored in a reference object set in the bullet screen distributing object, and when the bullet screen distributing object needs to distribute bullet screen messages, the bullet screen receiving object, namely a target bullet screen receiving object, which is to receive the bullet screen messages is determined from the object set according to the message identifier of the bullet screen messages to be distributed. And then, in order to call the target bullet screen receiving object later by using the communication function obtained by inheritance of the target bullet screen receiving object without calling the corresponding message processing function in the bullet screen receiving object, the target bullet screen receiving object is forcibly converted into a bullet screen distribution protocol type according to the bullet screen distribution protocol type corresponding to the bullet screen distribution protocol, and a receiving protocol object with the communication function of the bullet screen distribution protocol is obtained and is used as the target receiving object. And then, the bullet screen distributing object takes the bullet screen message as a function input parameter, the bullet screen distributing function in the bullet screen distributing object is called through the target receiving object, so that the target receiving object is triggered to call back the corresponding bullet screen distributing function, and the bullet screen message sent by the bullet screen distributing object as the function input parameter is received. The method has the advantages that a communication channel which is specially used for bullet screen message distribution between the bullet screen distributing object and the bullet screen receiving object is established, and the bullet screen message distribution efficiency is further improved.
Example two
In this embodiment, based on the first embodiment, the optimization is further performed on "meeting the multithreading bullet screen distribution condition". On the basis, the method can further optimize the current concurrency number of the barrage messages determined according to the current system state parameter values. On the basis, optimization can be further performed on the fact that all bullet screen messages with sequence relevance in all bullet screen messages to be distributed are determined to be relevant bullet screen messages. On the basis, the method can further optimize the distribution of the associated bullet screen messages by utilizing the associated thread. Explanations of the same or corresponding terms as those in the above embodiments are omitted herein. The execution main body of the embodiment is still a bullet screen distribution object. Referring to fig. 2, the bullet screen dispatching method with multithread synchronization provided by this embodiment includes:
s201, when the current timing period of the message concurrency timer is reached, determining the current concurrency number according to the current CPU occupancy rate and a preset concurrency number solving formula.
The message concurrent timer is used for triggering the multi-thread concurrent distribution of the bullet screen messages. The current timing cycle refers to a timing duration of a message concurrence timer at the current time, and may be a preset duration with a fixed value (i.e., a preset duration) or a dynamic duration dynamically adjusted according to a set adjustment rule. Illustratively, the current timing period is determined based on a last historical concurrency number of the current concurrency number. The historical concurrency number refers to the concurrency number of the historical time before the current time, and corresponds to the current concurrency number. The last historical concurrency number refers to the concurrency number of the historical time closest to the current time. In particular, after the previous historical concurrency number is determined, the current timing period can be determined according to the previous historical concurrency number. In this embodiment, the relationship between the current timing cycle and the previous historical concurrency number is set as a negative correlation relationship, if the previous historical concurrency number is larger, it indicates that the current available system resources are rich, and it can be considered that the distribution speed of the bullet screen messages is higher, a current timing cycle with a shorter duration can be set, so that each bullet screen message can be distributed more timely; and otherwise, setting a current timing cycle with longer duration to ensure that the previous batch of bullet screen messages distributed in parallel can be completely distributed, and avoiding overlarge system power consumption caused by parallel distribution of a plurality of batches of bullet screen messages. The current timing period is adjusted once for the distribution process and is determined before S110 is performed. The method has the advantages that the current timing period of the message concurrency timer can be dynamically determined according to the current system running state, so that the concurrent distribution of the bullet screen messages is triggered more accurately, and the distribution efficiency and timeliness of the bullet screen messages are further improved.
Specifically, the bullet screen distribution object first determines whether the current timing period of the message concurrence timer is reached. And when the bullet screen distribution object reaches the judgment result, acquiring the current CPU occupancy rate of the Android system. And then, the bullet screen distribution object calculates the current concurrency quantity according to a concurrency quantity solving formula between the current CPU occupancy rate and the current concurrency quantity. The concurrency number solving formula specifically comprises:
ParaNum=10-(int)(CpuOcRate*100/10)
in the formula, ParaNum is the current concurrency number, int is a rounding keyword, and CpuOcRate is the current CPU occupancy rate. The formula is constructed according to the following steps: in order to avoid the excessive number of threads opened at a time, in this embodiment, the maximum number of threads opened at a time is set to 10, that is, under the permission of available resources of the system, 10 bullet screen messages can be distributed at most at one time in parallel. Then, the current concurrency number CpuOcRate in percentage form is changed to a real number, i.e., CpuOcRate 100; then, in order to ensure that the finally determined concurrency number is a value less than or equal to 10, the value of the real number obtained above, namely CpuOcRate 100/10; meanwhile, in order to ensure that the calculation result is an integer, the int rounding keyword is used for rounding the result downwards. Finally, in order to make the CPU occupancy rate negatively correlated with the concurrency number so as to conform to the correlation specification in S110, the difference is made between the maximum value 10 of the concurrency number and the rounded result.
S202, acquiring the bullet screen messages to be distributed in the current concurrency quantity from the message set, and determining the distribution threads in the current concurrency quantity.
S203, determining an object set corresponding to each bullet screen message to be distributed according to the message identification of each bullet screen message to be distributed.
The object set is a set formed by all bullet screen receiving objects which need to receive bullet screen messages to be distributed.
Specifically, the bullet screen distributing object determines at least one bullet screen receiving object corresponding to the bullet screen message to be distributed according to the message identifier of the bullet screen message to be distributed and the message identifier list of each bullet screen receiving object capable of receiving the bullet screen message, so as to form an object set corresponding to the bullet screen message to be distributed. And executing the operation aiming at each bullet screen message to be distributed, so as to obtain an object set corresponding to each bullet screen message to be distributed.
And S204, determining the bullet screen messages to be distributed corresponding to the associated object sets with the same bullet screen receiving objects in the object sets as the associated bullet screen messages.
The associated object set refers to an object set corresponding to the associated bullet screen message. Since the number of the associated bullet screen messages is at least two, the number of the associated object sets is at least two.
Specifically, according to the message sequence of the bullet screen messages to be distributed, the bullet screen distribution object compares every two adjacent object sets of the bullet screen messages to be distributed to judge whether the same bullet screen receiving object exists in every two object sets. And if the judgment result shows that the two object sets exist in any pair, determining the two object sets as the associated object sets, and determining the bullet screen messages to be distributed corresponding to the two associated object sets as the two associated bullet screen messages. If the judgment result shows that the bullet screen information to be distributed does not exist, the bullet screen information to be distributed corresponding to the two object sets does not have sequential relevance. After all the object sets are traversed according to the process, all the associated bullet screen messages in the current concurrent number of bullet screen messages to be distributed can be determined.
For example, if the object set 1 corresponding to the message 1 includes the bullet screen receiving object A, B, the object set 2 corresponding to the message 2 includes the bullet screen receiving object B, C, the object set 3 corresponding to the message 3 includes the bullet screen receiving object C, and the object set 4 corresponding to the message 4 includes the bullet screen receiving object D, the message 1, the message 2, and the message 3 can all be determined as associated bullet screen messages, that is, all bullet screen messages to be distributed include 3 associated bullet screen messages.
And S205, determining the distribution threads corresponding to the associated bullet screen messages as the associated threads.
S206, according to the message sequence of each associated barrage message, taking the first associated barrage message as the current barrage message, and taking the associated thread corresponding to the current barrage message as the current associated thread. Thereafter, S207 or S209 is executed.
And S207, when all the associated threads run in a serial mode completely, based on a bullet screen message distribution mechanism, distributing the current bullet screen message to each bullet screen receiving object of the target object set by using the current associated thread, and when the current bullet screen message is not the last associated bullet screen message, based on a pre-constructed thread communication channel, sending a thread starting message to the next associated thread corresponding to the next associated bullet screen message through the current associated thread so as to trigger the operation of the next associated thread.
Specifically, when the associated distribution process is complete sequential distribution, all associated threads may run in a serial manner one after another according to message sequencing, a first associated thread in the serial manner may automatically perform distribution operation, and a subsequent thread start message sent by more than one associated thread is used as a trigger condition for execution of distribution operation during running of each associated thread. The dispatch operation in each associated thread is: and distributing the current bullet screen message to each bullet screen receiving object in the corresponding object set (namely the target object set) based on a bullet screen message distribution mechanism. The other steps are explained in the corresponding explanation of the first embodiment. Thereafter, S208 is executed to form a loop operation of S207 and S208.
And S208, updating the current bullet screen message into a next associated bullet screen message, updating the current associated thread into a next associated thread, and returning to execute the operation that when all associated threads run in a serial mode, the current associated thread is used for distributing the current bullet screen message to each bullet screen receiving object of the target object set based on a bullet screen message distribution mechanism.
S209, when the associated threads run in a partially serial mode, based on a bullet screen message distribution mechanism, distributing the current bullet screen message to the associated bullet screen receiving objects in the target object set by using the current associated thread, and when the current bullet screen message is not the last associated bullet screen message, based on a pre-constructed thread communication channel, sending a thread starting message to the next associated thread corresponding to the next associated bullet screen message by using the current associated thread to trigger the running of the next associated thread, and distributing the current bullet screen message to the remaining bullet screen receiving objects in the target object set by using the current associated thread.
The associated bullet screen receiving object refers to the same bullet screen receiving object in the object set corresponding to the target object set and the next associated bullet screen message. The remaining bullet screen receiving objects refer to other bullet screen receiving objects except the associated bullet screen object in the target object set.
Specifically, when the associated distribution process is partial sequential distribution, each associated thread may further distinguish each bullet screen receiving object in the object set, sequentially distribute bullet screen messages related to the associated bullet screen receiving objects, and concurrently distribute bullet screen messages of the remaining bullet screen receiving objects. In specific implementation, the current associated thread distributes the current barrage message to each associated barrage receiving object in the target object set based on a barrage message distribution mechanism. Thereafter, a thread start message is sent to the next associated thread to cause the next associated thread to start running. And then, the current associated thread distributes the current barrage message to each remaining barrage receiving object in the target object set based on a barrage message distribution mechanism.
For example, if the current bullet screen message is message 1, the current associated thread is a distribution thread corresponding to message 1, and the target object set is object set 1. Then, the distribution process of the message 1 is: the bullet screen distributing object firstly utilizes the current associated thread to distribute the message 1 to the bullet screen receiving object B, then triggers the distributing thread corresponding to the message 2 to run, namely triggers the next associated thread to distribute the message 2 to the bullet screen receiving object B, and then utilizes the current associated thread to distribute the message 1 to the bullet screen receiving object A. Thus, the operation of distributing the message 1 to the bullet screen receiving object a and the operation of distributing the message 2 to the bullet screen receiving object B can be in the parallel distribution state.
It should be understood that the bullet screen message distribution operation of the remaining bullet screen receiving objects and the bullet screen message distribution operation of the subsequent associated thread are in a parallel distribution state. The other steps are explained in the corresponding explanation of the first embodiment. Thereafter, S210 is executed to form loop operations of S209 and S210.
S210, updating the current bullet screen message into a next associated bullet screen message, updating the current associated thread into a next associated thread, and returning to execute the operation that when the associated threads run partially in a serial mode, the current associated thread is used for distributing the current bullet screen message to the associated bullet screen receiving object in the target object set based on a bullet screen message distribution mechanism.
And S211, distributing each residual bullet screen message in each bullet screen message to be distributed in parallel by using each residual thread in each distribution thread based on a bullet screen message distribution mechanism.
S207 to S208 and S209 to S210 are parallel steps, and one of the two groups may be selected to be executed. The execution sequence of S211 and S207 to S208 (or S209 to S210) is not limited, and may be executed in the above sequence, or S211 may be executed first and then S207 to S208 (or S209 to S210) may be executed, and preferably, S211 and S207 to S208 (or S209 to S210) are executed simultaneously, so as to further improve the distribution efficiency and the distribution timeliness of the bullet screen message.
According to the technical scheme of the embodiment, the associated bullet screen message is determined through the bullet screen receiving object corresponding to the bullet screen message to be distributed, so that the determination process of the associated bullet screen message can be simplified. The multithreading bullet screen message distribution condition is set to be the current timing period of the message concurrence timer, so that the trigger condition for the parallel distribution of the bullet screen messages is more normalized, the problem that the bullet screen messages cannot be distributed in time due to the fact that the trigger condition cannot be met is solved, and the timeliness of bullet screen message distribution is further improved. The current system state parameter value is determined as the current CPU occupancy rate, and the current concurrency quantity is determined by utilizing the concurrency quantity solving formula between the current CPU occupancy rate and the current concurrency quantity, so that the accuracy of determining the current concurrency quantity is improved, and the bullet screen message distribution efficiency is further improved. By distributing the current barrage message to all barrage receiving objects in the target object set, the complete serial operation of each associated thread is realized, and barrage associated distribution logic can be simplified. By distributing the current barrage message to each associated barrage receiving object in the target object set and distributing the current barrage message to each remaining barrage receiving object in the target object set when the next associated thread runs, partial serial running of each associated thread is realized, and the distribution efficiency and the distribution timeliness of the barrage message can be further improved to a certain extent.
The following is an embodiment of the multi-thread synchronized bullet screen dispensing device provided in the embodiments of the present invention, which belongs to the same inventive concept as the multi-thread synchronized bullet screen dispensing method in the above embodiments, and reference may be made to the embodiment of the multi-thread synchronized bullet screen dispensing method for details that are not described in detail in the embodiments of the multi-thread synchronized bullet screen dispensing device.
EXAMPLE III
The present embodiment provides a multi-thread synchronous bullet screen dispensing device, referring to fig. 3, the device specifically includes:
a concurrent bullet screen and thread determining module 310, configured to determine, when a multithreading bullet screen distribution condition is met, a current concurrency number of bullet screen messages according to a current system state parameter value, obtain, from a message set, bullet screen messages to be distributed in the current concurrency number, and determine distribution threads in the current concurrency number;
the associated bullet screen and thread determining module 320 is configured to determine bullet screen messages with sequence association in each bullet screen message to be distributed as associated bullet screen messages, and determine distribution threads corresponding to each associated bullet screen message as associated threads;
the bullet screen message distribution module 330 is configured to distribute, based on a bullet screen message distribution mechanism, each associated bullet screen message in an associated manner by using each associated thread, and distribute, in parallel, each remaining bullet screen message in each bullet screen message to be distributed by using each remaining thread in each distribution thread.
Optionally, the associated barrage and thread determining module 320 is specifically configured to:
determining an object set corresponding to each bullet screen message to be distributed according to the message identifier of each bullet screen message to be distributed;
and determining bullet screen messages to be distributed corresponding to associated object sets with the same bullet screen receiving objects in the object sets as the associated bullet screen messages, wherein the number of the associated object sets is at least two.
Optionally, the bullet screen message distribution module 330 includes:
the current barrage message and associated thread determining submodule is used for taking the first associated barrage message as the current barrage message and taking the associated thread corresponding to the current barrage message as the current associated thread according to the message sequence of each associated barrage message;
the bullet screen message distribution submodule is used for distributing the current bullet screen message by using the current associated thread, and sending a thread starting message to the next associated thread corresponding to the next associated bullet screen message through the current associated thread based on a pre-constructed thread communication channel when the current bullet screen message is not the last associated bullet screen message so as to trigger the operation of the next associated thread;
and the circulation submodule is used for updating the current barrage message into the next associated barrage message, updating the current associated thread into the next associated thread, and returning to execute the operation of distributing the current barrage message by using the current associated thread.
The bullet screen message distribution submodule is specifically configured to:
and when all the associated threads run in a serial mode completely, distributing the current barrage message to all the barrage receiving objects of the target object set by using the current associated threads.
Alternatively, the bullet screen message distribution submodule is specifically configured to:
when the associated threads run in a partially serial mode, the current associated thread is used for distributing the current barrage message to the associated barrage receiving objects in the target object set, and when the current barrage message is not the last associated barrage message, based on a pre-constructed thread communication channel, the thread starting message is sent to the next associated thread corresponding to the next associated barrage message through the current associated thread to trigger the running of the next associated thread, and the current associated thread is used for distributing the current barrage message to the rest barrage receiving objects in the target object set.
Optionally, satisfying the multithreading bullet screen distribution condition includes: and the current timing period of the message concurrency timer arrives, wherein the current timing period is determined according to the last historical concurrency number of the current concurrency number.
Optionally, the concurrent barrage and thread determining module 310 is specifically configured to:
and when the system state parameter is the current CPU occupancy rate, determining the current concurrency quantity according to the current CPU occupancy rate and a preset concurrency quantity solving formula.
By the aid of the multi-thread synchronous bullet screen distributing device, bullet screen messages can be distributed sequentially and efficiently, and distribution timeliness and distribution accuracy of the bullet screen messages are improved.
The multi-thread synchronous bullet screen distribution device provided by the embodiment of the invention can execute the multi-thread synchronous bullet screen distribution method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the multi-thread synchronous bullet screen dispensing device, each included unit and module are only divided according to functional logic, but are not limited to the above division, as long as the corresponding function can be realized; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
Example four
Referring to fig. 4, the present embodiment provides an apparatus 400 comprising: one or more processors 420; the storage device 410 is configured to store one or more programs, and when the one or more programs are executed by the one or more processors 420, the one or more processors 420 implement the multi-thread synchronization bullet-screen distribution method provided in the embodiment of the present invention, including:
when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed with the current concurrency number from the message set, and determining the distribution threads with the current concurrency number;
determining bullet screen messages with sequence relevance in all bullet screen messages to be distributed as associated bullet screen messages, and determining distribution threads corresponding to all the associated bullet screen messages as associated threads;
based on a bullet screen message distribution mechanism, distributing each associated bullet screen message by using each associated thread in an associated manner, and distributing each residual bullet screen message in each bullet screen message to be distributed in parallel by using each residual thread in each distribution thread.
Of course, those skilled in the art can understand that the processor 420 can also implement the technical solution of the multi-thread synchronous bullet screen distribution method provided by any embodiment of the present invention.
The apparatus 400 shown in fig. 4 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present invention. As shown in fig. 4, the apparatus 400 includes a processor 420, a storage device 410, an input device 430, and an output device 440; the number of the processors 420 in the device may be one or more, and one processor 420 is taken as an example in fig. 4; the processor 420, the storage device 410, the input device 430 and the output device 440 of the apparatus may be connected by a bus or other means, for example, the bus 450 in fig. 4.
The storage device 410 is a computer-readable storage medium, and can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the multi-thread synchronous bullet screen distribution method in the embodiment of the present invention (for example, a concurrent bullet screen and thread determination module, an associated bullet screen and thread determination module, and a bullet screen message distribution module in the multi-thread synchronous bullet screen distribution device).
The storage device 410 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the storage 410 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the storage 410 may further include memory located remotely from the processor 420, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the apparatus. The output device 440 may include a display device such as a display screen.
EXAMPLE five
The present embodiments provide a storage medium containing computer-executable instructions which, when executed by a computer processor, perform a method of bullet screen dispensing with multi-thread synchronization, the method comprising:
when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed with the current concurrency number from the message set, and determining the distribution threads with the current concurrency number;
determining bullet screen messages with sequence relevance in all bullet screen messages to be distributed as associated bullet screen messages, and determining distribution threads corresponding to all the associated bullet screen messages as associated threads;
based on a bullet screen message distribution mechanism, distributing each associated bullet screen message by using each associated thread in an associated manner, and distributing each residual bullet screen message in each bullet screen message to be distributed in parallel by using each residual thread in each distribution thread.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform related operations in the multi-thread synchronization bullet screen distribution method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) to execute the bullet screen distribution method with multithread synchronization provided by the embodiments of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A multi-thread synchronous bullet screen distribution method is characterized by comprising the following steps:
when the multithreading bullet screen distribution condition is met, determining the current concurrency number of bullet screen messages according to the current system state parameter values, acquiring the bullet screen messages to be distributed in the current concurrency number from a message set, and determining the distribution threads in the current concurrency number;
determining bullet screen messages with sequence relevance in the bullet screen messages to be distributed as associated bullet screen messages, and determining distribution threads corresponding to the associated bullet screen messages as associated threads;
based on a bullet screen message distribution mechanism, distributing the associated bullet screen messages by using the associated thread associations, and distributing the remaining bullet screen messages in the bullet screen messages to be distributed in parallel by using the remaining threads in the distribution threads.
2. The method of claim 1, wherein determining bullet screen messages with sequence relevance in each bullet screen message to be distributed as relevant bullet screen messages comprises:
determining an object set corresponding to each bullet screen message to be distributed according to the message identifier of each bullet screen message to be distributed;
determining the bullet screen messages to be distributed corresponding to the associated object sets with the same bullet screen receiving objects in the object sets as the associated bullet screen messages, wherein the number of the associated object sets is at least two.
3. The method of claim 1, wherein distributing each associated bullet screen message with each associated thread association comprises:
according to the message sequence of each associated barrage message, taking the first associated barrage message as a current barrage message, and taking the associated thread corresponding to the current barrage message as a current associated thread;
distributing a current barrage message by using a current associated thread, and sending a thread starting message to a next associated thread corresponding to a next associated barrage message through the current associated thread based on a pre-constructed thread communication channel when the current barrage message is not the last associated barrage message so as to trigger the operation of the next associated thread;
and updating the current barrage message into a next associated barrage message, updating the current associated thread into a next associated thread, and returning to execute the operation of distributing the current barrage message by using the current associated thread.
4. The method of claim 3, wherein distributing the current barrage message using the current associated thread comprises:
and when all the associated threads run in a serial mode completely, distributing the current barrage message to all the barrage receiving objects of the target object set by using the current associated threads.
5. The method of claim 3, wherein the distributing a current barrage message by using a current associated thread, and when the current barrage message is not a last associated barrage message, sending a thread start message to a next associated thread corresponding to a next associated barrage message by using the current associated thread based on a pre-constructed thread communication channel comprises:
when the associated threads run in a partially serial mode, the current associated thread is used for distributing the current barrage message to the associated barrage receiving objects in the target object set, and when the current barrage message is not the last associated barrage message, based on a pre-constructed thread communication channel, the thread starting message is sent to the next associated thread corresponding to the next associated barrage message through the current associated thread to trigger the running of the next associated thread, and the current associated thread is used for distributing the current barrage message to the rest barrage receiving objects in the target object set.
6. The method of claim 1, wherein satisfying the multithreaded bullet screen distribution condition comprises: and the current timing period of the message concurrency timer arrives, wherein the current timing period is determined according to the last historical concurrency number of the current concurrency number.
7. The method of claim 1, wherein determining the current number of concurrencies for the bullet screen message based on the current system state parameter value comprises:
and when the system state parameter is the current CPU occupancy rate, determining the current concurrency quantity according to the current CPU occupancy rate and a preset concurrency quantity solving formula.
8. A multi-thread synchronized bullet screen dispensing apparatus, comprising:
the concurrent bullet screen and thread determining module is used for determining the current concurrency quantity of bullet screen messages according to the current system state parameter values when the multithreading bullet screen distribution condition is met, acquiring the bullet screen messages to be distributed in the current concurrency quantity from a message set, and determining the distribution threads in the current concurrency quantity;
the associated bullet screen and thread determining module is used for determining bullet screen messages with sequence association in the bullet screen messages to be distributed as associated bullet screen messages and determining the distribution threads corresponding to the associated bullet screen messages as associated threads;
and the bullet screen message distribution module is used for distributing the associated bullet screen messages in an associated manner by using the associated threads based on a bullet screen message distribution mechanism, and distributing the remaining bullet screen messages in the bullet screen messages to be distributed in parallel by using the remaining threads in the distribution threads.
9. An apparatus, characterized in that the apparatus comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the multi-threaded synchronized bullet screen dispensing method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements a multi-threaded synchronized bullet screen dispensing method according to any one of claims 1 to 7.
CN201811151399.8A 2018-09-29 2018-09-29 Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium Active CN109246470B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811151399.8A CN109246470B (en) 2018-09-29 2018-09-29 Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811151399.8A CN109246470B (en) 2018-09-29 2018-09-29 Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109246470A CN109246470A (en) 2019-01-18
CN109246470B true CN109246470B (en) 2020-10-16

Family

ID=65054165

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811151399.8A Active CN109246470B (en) 2018-09-29 2018-09-29 Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109246470B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110460865A (en) * 2019-07-23 2019-11-15 中国农业大学 Extensive barrage acquisition methods and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101188570A (en) * 2006-11-17 2008-05-28 鸿富锦精密工业(深圳)有限公司 Instant message processing system and method
US7986639B1 (en) * 2004-10-26 2011-07-26 Sprint Communications Company L.P. Topology management of a communications network
CN106155794A (en) * 2016-07-21 2016-11-23 浙江大华技术股份有限公司 A kind of event dispatcher method being applied in multi-threaded system and device
CN106325980A (en) * 2015-06-30 2017-01-11 中国石油化工股份有限公司 Multi-thread concurrent system
CN106874031A (en) * 2017-01-03 2017-06-20 青岛海信电器股份有限公司 A kind of startup method and device of terminal device system program
CN107193539A (en) * 2016-03-14 2017-09-22 北京京东尚科信息技术有限公司 Multi-thread concurrent processing method and multi-thread concurrent processing system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7986639B1 (en) * 2004-10-26 2011-07-26 Sprint Communications Company L.P. Topology management of a communications network
CN101188570A (en) * 2006-11-17 2008-05-28 鸿富锦精密工业(深圳)有限公司 Instant message processing system and method
CN106325980A (en) * 2015-06-30 2017-01-11 中国石油化工股份有限公司 Multi-thread concurrent system
CN107193539A (en) * 2016-03-14 2017-09-22 北京京东尚科信息技术有限公司 Multi-thread concurrent processing method and multi-thread concurrent processing system
CN106155794A (en) * 2016-07-21 2016-11-23 浙江大华技术股份有限公司 A kind of event dispatcher method being applied in multi-threaded system and device
CN106874031A (en) * 2017-01-03 2017-06-20 青岛海信电器股份有限公司 A kind of startup method and device of terminal device system program

Also Published As

Publication number Publication date
CN109246470A (en) 2019-01-18

Similar Documents

Publication Publication Date Title
CN109413502B (en) Multithreading barrage message distribution method, device, equipment and storage medium
CN109918141B (en) Thread execution method, thread execution device, terminal and storage medium
WO2019114129A1 (en) Scheduling device and method for push server and computer-readable storage medium
US20220400028A1 (en) Operation control method and device, household electrical appliance, and storage medium
CN112988362B (en) Task processing method and device, electronic equipment and storage medium
CN110471763B (en) Scheduling method, system, medium and electronic equipment based on shared object pool
KR20130024801A (en) Terminal and method for managing application thereof
CN109062650B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109246470B (en) Multi-thread synchronous bullet screen distribution method, device, equipment and storage medium
WO2020181812A1 (en) Application broadcast message push method, apparatus, and readable storage medium
CN109379605B (en) Bullet screen distribution method, device, equipment and storage medium based on bullet screen sequence
CN109413489B (en) Serial multi-thread bullet screen distribution method, device, equipment and storage medium
CN109819674B (en) Computer storage medium, embedded scheduling method and system
CN111813529B (en) Data processing method, device, electronic equipment and storage medium
WO2024001411A1 (en) Multi-thread scheduling method and device
CN109005465B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109274988B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109309848B (en) Bullet screen distribution method, device, equipment and storage medium based on retry mechanism
CN109086115B (en) Android animation execution method, device, terminal and readable medium
CN109144639B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109086107B (en) Bullet screen message distribution method, device, equipment and storage medium
CN106919488B (en) Method and device for determining response state of application program
CN108810645A (en) Barrage message distributing method, device, equipment and storage medium
CN109005448B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109684009B (en) Protocol-based countdown synchronization method, device, storage medium and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant