CN107818023A - Thread-based message processing method, intelligent device and storage medium - Google Patents

Thread-based message processing method, intelligent device and storage medium Download PDF

Info

Publication number
CN107818023A
CN107818023A CN201711082986.1A CN201711082986A CN107818023A CN 107818023 A CN107818023 A CN 107818023A CN 201711082986 A CN201711082986 A CN 201711082986A CN 107818023 A CN107818023 A CN 107818023A
Authority
CN
China
Prior art keywords
function
thread
type
message
intended recipient
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.)
Granted
Application number
CN201711082986.1A
Other languages
Chinese (zh)
Other versions
CN107818023B (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.)
Shenzhen Leynew Network Media Co Ltd
Original Assignee
Shenzhen Leynew Information 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 Shenzhen Leynew Information Technology Co ltd filed Critical Shenzhen Leynew Information Technology Co ltd
Priority to CN201711082986.1A priority Critical patent/CN107818023B/en
Publication of CN107818023A publication Critical patent/CN107818023A/en
Application granted granted Critical
Publication of CN107818023B publication Critical patent/CN107818023B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The invention discloses a message processing method based on threads, intelligent equipment and a storage medium. When the intelligent equipment detects a sending function, the intelligent equipment acquires the target thread type of the sending function, searches a receiving function corresponding to the target thread type in a current receiving function set, takes the searched receiving function as a target receiving function, and distributes messages in the target thread where the target receiving function is located through the target receiving function. The method and the device realize the determination of different executable receiving functions based on different sending functions, and overcome the technical problem that the better coupling between the sending functions and the receiving functions cannot be ensured in the Android system.

Description

Message treatment method, smart machine and storage medium based on thread
Technical field
The present invention relates to Android (Android) system regions, more particularly to the message treatment method based on thread, intelligence to set Standby and storage medium.
Background technology
As the continuous development of android system is with being applicable, the message processor of android system is made as Android The main realization principle that message sends and received is carried out in system, key effect is played in the operation of android system.But It is, with the progressively application of android system, in the exploitation link of system or application program, in order to preferably realize tool Body function, may in the program of developer in various inner classes occur, and realize various communication interfaces, also just reduce The side of broadcasting and the coupling of recipient.
For example an anonymous subclass Handler may be realized below a function in code again, this can cause to send out Do not have preferable coupling between the function for the side of sending and the function of recipient, so, current android system is at message It can not ensure to send during reason between function and receiver function and maintain preferable coupling, so, current Android System presence can not ensure to send the technical problem that preferable coupling is maintained between function and receiver function.
The above is only used for auxiliary and understands technical scheme, does not represent and recognizes that the above is existing skill Art.
The content of the invention
It is a primary object of the present invention to provide the message treatment method based on thread, smart machine and storage medium, purport Solving not ensureing to send existing for android system in the prior art between function and receiver function to maintain preferable coupling The technical problem of conjunction property.
To achieve the above object, the present invention provides a kind of message treatment method based on thread, and methods described includes following Step:
Smart machine obtains the subject thread type for sending function when detecting transmission function;
Receiver function corresponding with the subject thread type is searched in current receiver function set, is connect what is found Function is received as intended recipient function;
Message distribution is carried out in the subject thread residing for the intended recipient function by the intended recipient function.
Preferably, the smart machine obtains the subject thread type for sending function when detecting transmission function Afterwards, the message treatment method based on thread also includes:
Obtain the objective function parameters type of the transmission function;
The current receiver function set corresponding to according to the objective function parameters type search, described in mapping relations Mapping relations include function parameter type and the corresponding relation of receiver function set, and the receiver function set includes each reception letter Number.
Preferably, the smart machine obtains the objective function parameters for sending function when detecting transmission function Before type, the message treatment method based on thread also includes:
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to default class object;
The sample function parameter type according to corresponding to determining the sample reception function;
Using each sample receiver function of the sample function parameter type identical as sample reception function set, institute is established The corresponding relation of sample function parameter type and the sample reception function set is stated, the corresponding relation is added into described reflect Penetrate in relation.
Preferably, it is described that each sample receiver function corresponding to class object acquisition is preset come basis based on Java reflex mechanism Before, the message treatment method based on thread also includes:
Obtain the reference information of the transmission function;
The default class object is generated according to the reference information.
Preferably, the reference information is class category informations;
Correspondingly, it is described that the default class object is generated according to the reference information, based on Java reflex mechanism come root According to each sample receiver function corresponding to the acquisition of default class object, specifically include:
Class class objects are generated according to the class category informations;
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to the class class objects.
Preferably, it is described to be carried out by the intended recipient function in the subject thread residing for the intended recipient function Message distribution, specifically include:
Identify the subject thread type;
When the subject thread type is main thread type, disappeared by the intended recipient function in main thread Breath distribution, the main thread type are corresponding with the main thread;
Or,
When the subject thread type is sub-line journey type, disappeared by the intended recipient function in sub-line journey Breath distribution, the sub-line journey type are corresponding with the sub-line journey.
Preferably, it is described when the subject thread type is main thread type, by the intended recipient function in master Message distribution is carried out in thread, is specifically included:
When the subject thread type is main thread type, pass through the intended recipient function call main thread Looper, so that the intended recipient function carries out message distribution in the main thread.
Preferably, it is described when the subject thread type is sub-line journey type, by the intended recipient function in son Message distribution is carried out in thread, is specifically included:
When the subject thread type is sub-line journey type, creates new thread and call the Looper of the new thread, So that the intended recipient function carries out message distribution in the new thread.
In addition, to achieve the above object, the present invention also provides a kind of smart machine, and the smart machine includes:Memory, Processor and the message processing program based on thread that can be run on the memory and on the processor is stored in, it is described Message processing program based on thread is arranged for carrying out the step of message treatment method based on thread as described above.
In addition, to achieve the above object, the present invention also provides a kind of storage medium, is stored with and is based in the storage medium The message processing program of thread, base as described above is realized when the message processing program based on thread is executed by processor In the message treatment method of thread the step of.
By finding receiver function corresponding with the subject thread type, the receiver function that will be found in the present invention Message distribution is carried out in subject thread as intended recipient function, and by the intended recipient function, is also achieved that base Different executable receiver functions is determined in different transmission functions, overcoming can not ensure present in android system Send the technical problem that preferable coupling is maintained between function and receiver function.
Brief description of the drawings
Fig. 1 is the smart machine structural representation for the hardware running environment that scheme of the embodiment of the present invention is related to;
Fig. 2 is the schematic flow sheet of the message treatment method first embodiment of the invention based on thread;
Fig. 3 is the schematic flow sheet of the message treatment method second embodiment of the invention based on thread;
Fig. 4 is the schematic flow sheet of the message treatment method 3rd embodiment of the invention based on thread;
Fig. 5 is the schematic flow sheet of the message treatment method fourth embodiment of the invention based on thread.
The realization, functional characteristics and advantage of the object of the invention will be described further referring to the drawings in conjunction with the embodiments.
Embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
Reference picture 1, Fig. 1 are the smart machine structural representation for the hardware running environment that scheme of the embodiment of the present invention is related to.
As shown in figure 1, the smart machine can include:Processor 1001, such as CPU, communication bus 1002, user interface 1003, network interface 1004, memory 1005.Wherein, communication bus 1002 is used to realize the connection communication between these components. User interface 1003 can include display screen (Display), optional user interface 1003 can also include standard wireline interface, Wave point, the wireline interface for user interface 1003 can be USB interface in the present invention.Network interface 1004 optionally may be used With the wireline interface including standard, wave point (such as WI-FI interfaces).Memory 1005 can be high-speed RAM memory, also may be used To be stable memory (non-volatile memory), such as magnetic disk storage.Memory 1005 optionally can also be Independently of the storage device of aforementioned processor 1001.
The smart machine may be based on the electronic equipments such as the smart mobile phone of android system, tablet personal computer.
It will be understood by those skilled in the art that the structure shown in Fig. 1 does not form the restriction to smart machine, can wrap Include than illustrating more or less parts, either combine some parts or different parts arrangement.
As shown in figure 1, it can lead to as in a kind of memory 1005 of computer-readable storage medium including operating system, network Believe module, Subscriber Interface Module SIM and the message processing program based on thread.
In the smart machine shown in Fig. 1, network interface 1004 is mainly used in connecting background server, is taken with the backstage Business device enters row data communication;User interface 1003 is mainly used in connecting peripheral hardware;The smart machine is called by processor 1001 The message processing program based on thread stored in memory 1005, and perform following operate:
When detecting transmission function, the subject thread type for sending function is obtained;
Receiver function corresponding with the subject thread type is searched in current receiver function set, is connect what is found Function is received as intended recipient function;
Message distribution is carried out in the subject thread residing for the intended recipient function by the intended recipient function.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
Obtain the objective function parameters type of the transmission function;
The current receiver function set corresponding to according to the objective function parameters type search, described in mapping relations Mapping relations include function parameter type and the corresponding relation of receiver function set, and the receiver function set includes each reception letter Number.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to default class object;
The sample function parameter type according to corresponding to determining the sample reception function;
Using each sample receiver function of the sample function parameter type identical as sample reception function set, institute is established The corresponding relation of sample function parameter type and the sample reception function set is stated, the corresponding relation is added into described reflect Penetrate in relation.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
Obtain the reference information of the transmission function;
The default class object is generated according to the reference information.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
Class class objects are generated according to the class category informations;
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to the class class objects.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
Identify the subject thread type;
When the subject thread type is main thread type, disappeared by the intended recipient function in main thread Breath distribution, the main thread type are corresponding with the main thread;
Or,
When the subject thread type is sub-line journey type, disappeared by the intended recipient function in sub-line journey Breath distribution, the sub-line journey type are corresponding with the sub-line journey.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
When the subject thread type is main thread type, pass through the intended recipient function call main thread Looper, so that the intended recipient function carries out message distribution in the main thread.
Further, processor 1001 can call the message processing program based on thread stored in memory 1005, Also perform following operate:
When the subject thread type is sub-line journey type, creates new thread and call the Looper of the new thread, So that the intended recipient function carries out message distribution in the new thread.
By finding receiver function corresponding with the subject thread type, the reception letter that will be found in the present embodiment Number is used as intended recipient function, and message distribution is carried out in subject thread by the intended recipient function, is also achieved that Different executable receiver functions is determined based on different transmission functions, overcoming can not protect present in android system Card sends the technical problem that preferable coupling is maintained between function and receiver function.
Based on above-mentioned hardware configuration, the embodiment of the proposition message treatment method of the invention based on thread.
Reference picture 2, Fig. 2 are the schematic flow sheet of the message treatment method first embodiment of the invention based on thread.
In the first embodiment, the message treatment method based on thread comprises the following steps:
Step S10:Smart machine obtains the subject thread type for sending function when detecting transmission function;
It is understood that work as the program based on android system upon execution, typically in the presence of between two functions Information exchanging process, such as, one sends function and communicates information to a receiver function as recipient as sender, but It is, because android system operationally has main thread and point of sub-line journey, when the executive mode for sending function has determined that When, actually or receiver function follow-up information transmission is carried out in main thread sub-line journey and is had differences.Wherein, main line Journey refers to the thread created with process initiation, and sub-line journey refers to the new thread created by the main thread.
In the specific implementation, for example, when running one in android system and sending function A, in order to determine the transmission Residing thread type when receiver function specifically performs corresponding to function, it can first obtain transmission function A subject thread type. Wherein, the subject thread type is set in advance as two types, respectively main thread type and sub-line journey type, main thread class Type represents that receiver function will be run in main thread, and sub-line journey type represents that receiver function will be run in sub-line journey.So hair The subject thread type of function is sent to be used to describe the thread type residing for corresponding receiver function.
Step S20:Receiver function corresponding with the subject thread type is found in current receiver function set, will The receiver function found is as intended recipient function;
It should be appreciated that after the subject thread type for sending function A is got, can be from current receiver function set Go to search receiver function corresponding to transmission function A.Wherein, current receiver function set has pre-saved various receiver functions. When being gone to search receiver function in current receiver function set according to subject thread type, due to the reception in receiver function set Function is different, the receiver function that can be run in main thread be present, there is also the receiver function that can be run in sub-line journey, So it will also go to mark receiver function by thread type.
It is understood that after being determined that the thread type for sending function A is subject thread type, such as, score Journey type is main thread type, can also be gone to find according to main thread type corresponding to intended recipient function B, so, find Intended recipient function B will be run in main thread.So thread will all be pre-set by sending function A and intended recipient function B Type.
Step S30:Disappeared by the intended recipient function in the subject thread residing for the intended recipient function Breath distribution.
It should be appreciated that for example, subject thread type is sub-line journey type, it is determined that intended recipient function to receive letter After number C, receiver function C will be called and run in sub-line journey, also just realized to sending receiver function corresponding to function A really It is fixed.Also, by the scheme described in the present embodiment, corresponding executable reception is all can determine that for different transmission functions Function;Meanwhile by neatly automatically determining corresponding receiver function, so that it may an anonymous son need not be realized again under function Class Handler, developed than it according to existing android system, the method described using the present embodiment causes code not It is in disorder again, improve readability.
Go to realize the technical scheme that the present embodiment describes in addition, pattern can be designed by singleton pattern, also allow for only In the presence of an instance objects, it is possible to achieve the unified management for function.
By finding receiver function corresponding with the subject thread type, the reception letter that will be found in the present embodiment Number is used as intended recipient function, and message distribution is carried out in subject thread by the intended recipient function, is also achieved that Different executable receiver functions is determined based on different transmission functions, overcoming can not protect present in android system Card sends the technical problem that preferable coupling is maintained between function and receiver function.Specifically, thread type will be based on Carry out the selection of receiver function so that the thread type of operation meets operation demand.
Reference picture 3, Fig. 3 are the schematic flow sheet of the message treatment method second embodiment of the invention based on thread, are based on Embodiment shown in above-mentioned Fig. 2, propose the second embodiment of the message treatment method of the invention based on thread.
In a second embodiment, after the step S10, methods described also includes:
Step S101:Obtain the objective function parameters type of the transmission function;
It is understood that information transmission can be carried out in order to ensure to send between function and receiver function, can preferentially by The function parameter type of receiver function determines with sending the function parameter type identical receiver function of function as the present embodiment Intended recipient function, to carry out message distribution.Because if transmission function is different from the function parameter type of receiver function, connect Function is received to will be unable to get the data for sending function passes.
Step S102:According to the objective function parameters type search to corresponding current receiver function in mapping relations Set, the mapping relations include function parameter type and the corresponding relation of receiver function set, the receiver function set bag Include each receiver function.
In the specific implementation, for example, if it is that to send function A objective function parameters type be integer to send function, due to It may be selected, Selection of Function parameter type can be carried out in each receiver function for the receiver function of integer in the presence of substantial amounts of receiver function Message distribution.In order to go to find the receiver function for meeting parameter type requirement according to function parameter type more quickly, can incite somebody to action Function parameter type identical receiver function is stored in same set, so as to form the receiver function set.So Determine send function function parameter type be integer after, can according to the above-mentioned mapping relations established, find with it is whole Receiver function set corresponding to type, then remove to determine the currently executable receiver function operated in the receiver function set, both soon Speed, also meet the parameter type identical requirement for sending function and receiver function.
In addition, the present embodiment by first determine send function objective function parameters type, then determine send function mesh Thread type is marked, to find corresponding receiver function in two steps.Lookup mode for receiver function, it can also establish a number According to structure, function parameter type and thread type are preserved simultaneously in the data structure, then can be directly by the data structure only Corresponding receiver function need to be found by a step.
Certainly, the container of a Map type can also be established to realize above-mentioned technical proposal.Specifically, Map types Key is function parameter type, and value corresponding to Key is above-mentioned data structure, then can be based on the Map containers and realize for receiving The determination of function, this example are not restricted to this.
By pre-establishing the mapping of the corresponding relation including function parameter type Yu receiver function set in the present embodiment Relation, it can more quickly determine the receiver function for meeting parameter type requirement.
Reference picture 4, Fig. 4 are the schematic flow sheet of the message treatment method 3rd embodiment of the invention based on thread, are based on Embodiment shown in above-mentioned Fig. 3, propose the 3rd embodiment of the message treatment method of the invention based on thread.
In the third embodiment, before the step S10, methods described also includes:
Step S101 ':Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to default class object;
It is understood that include function parameter type pass corresponding with receiver function set to more neatly establish The mapping relations of system, it can go to realize the foundation for mapping relations based on Java reflex mechanism.Wherein, the reflection based on Java Mechanism refers to that program can access under Java use environment, detected and modification state itself or a kind of ability of behavior, tool For body, the name of class is only needed to obtain the relevant information of class based on reflex mechanism.
In the specific implementation, can first allow user to specify item name, so that it may based on reflex mechanism come dynamic load classification, So as to obtain the relevant information of the category.For example the relevant information of above-mentioned classification first can be encapsulated as into an object i.e. described pre- If class object, after the default class object is got, preset class object further according to this and remove each sample receiver function corresponding to acquisition. As for the mode that class object acquisition sample reception function is preset according to this, the getMethods side of Java reflex mechanism can be passed through Method presets each sample receiver function corresponding to class object to obtain this.
Step S102 ':The sample function parameter type according to corresponding to determining the sample reception function;
It should be appreciated that after each sample receiver function is got, in order to establish above-mentioned mapping relations, can first determine The sample function parameter type of each sample receiver function.
Step S103 ':Using each sample receiver function of the sample function parameter type identical as sample reception function Set, the corresponding relation of the sample function parameter type and the sample reception function set is established, by the corresponding relation It is added into the mapping relations.
In the specific implementation, for example, if the sample reception function got according to default class object is respectively receiver function A1, B1 and C1, and receiver function A1, B1 and C1 function parameter type are respectively integer, integer and floating type, so, it will connect Receive function A1 and B1 to be saved into the corresponding receiver function set of integer type, receiver function C1 is saved into floating type type pair In the receiver function set answered, the corresponding relation of function parameter type and receiver function set is also just established, enriches mapping Workable corresponding relation in relation;And so that during specific implementation, send function rapidly can join according to function Receiver function corresponding to several classes of types determinations.
Further, it is described before the step S101 ' in order to make default class object more abundant and variant Method also includes:
Step S1011:Obtain the reference information of the transmission function;
It is understood that default class object can be established based on the reference information for sending function, because reference information can Preferably to describe to send the details of function.
Step S1012:The default class object is generated according to the reference information.
In the specific implementation, reference information may include the information such as class name, the method for statement, the field of statement, different type Reference information generation default class object it is distinct.For example the default class object of generation is encapsulated according to reference information, can be Class classes, Method classes and Field classes etc..So by generating default class object according to reference information, can be cleverer Default class object is obtained livingly;Also, the default class object for going to get by this kind of mode, it can preferably describe to send letter Number, so that the mapping relations finally established can more accurately determine receiver function.
Further, the reference information is class category informations, that is, describes the class name information in reference information, described The default class object is generated according to the reference information, based on Java reflex mechanism come according to corresponding to default class object acquisition Each sample receiver function, is specifically included:Class class objects, the reflex mechanism based on Java are generated according to the class category informations Carry out each sample receiver function according to corresponding to obtaining the class class objects.
If in the specific implementation, the reference information got for send function class category informations, can be according to the class Category information obtains each sample receiver function corresponding to the class classes.This kind obtains the mode of receiver function, real without creating Example, the class classes in the default class object can be only carried out, if also allowing for developing program in the side described based on the present embodiment When formula is write or run, both succinctly, it is readable strong, suitable receiver function can also be determined well.
By presetting each sample reception corresponding to class object acquisition based on Java reflex mechanism come basis in the present embodiment Function, and then the corresponding relation of the sample function parameter type and the sample reception function set is established, can be cleverer The mapping relations of the corresponding relation including function parameter type Yu receiver function set are established livingly;It is meanwhile above-mentioned by application Mapping relations so that send function can more neatly according to function parameter type determine corresponding to receiver function.
Reference picture 5, Fig. 5 are the schematic flow sheet of the message treatment method fourth embodiment of the invention based on thread, are based on Embodiment shown in above-mentioned Fig. 2, propose the fourth embodiment of the message treatment method of the invention based on thread.
In the fourth embodiment, the step S30, is specifically included:
Step S301:Identify the subject thread type;
It is understood that residing thread type during in order to determine receiver function operation, can first identify the score Journey type.Wherein, the subject thread type is set in advance as two types, respectively main thread type and sub-line journey type, Main thread type represents that receiver function will be run in main thread, and sub-line journey type represents that receiver function will be transported in sub-line journey OK.So the subject thread type is used to describe the thread type residing for corresponding receiver function.
Step S302:When the subject thread type is main thread type, by the intended recipient function in main line Message distribution is carried out in journey, the main thread type is corresponding with the main thread.
It should be appreciated that when the thread type identified is main thread type, it is determined that intended recipient function will be Run in main thread;When the thread type identified is sub-line journey type, it is determined that intended recipient function will be in sub-line journey Operation so that different types of receiver function stable operation in the running environment that itself is adapted to.
Further, it is described when the subject thread type is main thread type, existed by the intended recipient function Message distribution is carried out in main thread, is specifically included:When the subject thread type is main thread type, connect by the target The Looper of function call main thread is received, so that the intended recipient function carries out message distribution in the main thread.
It is understood that in the message processing facility of android system, message will be realized by four primary clusterings Processing, it is respectively, message class Message classes, Message Opcode class Handle classes, message channel Looper and target.Wherein, One thread only has a Looper, for being that message is taken out in circulation in order in message queue from Message Queue.Institute So that main thread is by with a Looper of itself.
In the specific implementation, when it is determined that subject thread type is main thread type, intended recipient function will be in main thread Middle carry out message distribution, specifically, because a thread only has a Looper, intended recipient function will call main thread certainly The Looper of body, to carry out the transmission of message and transmission.
In addition, when the subject thread type is sub-line journey type, by the intended recipient function in sub-line journey Message distribution is carried out, the sub-line journey type is corresponding with the sub-line journey.
Further, it is described when the subject thread type is sub-line journey type, existed by the intended recipient function Message distribution is carried out in sub-line journey, is specifically included:When the subject thread type is sub-line journey type, creates new thread and adjust With the Looper of the new thread, so that the intended recipient function carries out message distribution in the new thread.
In the specific implementation, when it is determined that subject thread type is sub-line journey type, intended recipient function will be in sub-line journey Middle carry out message distribution, message distribution will be carried out in the new thread that main thread creates.Because a thread only has one Looper, so, the intended recipient function will not call the Looper of main thread, but call oneself of the new thread created The Looper of body, message distribution is carried out in new thread to realize, it is achieved thereby that on the premise of preferable coupling is ensured, Complete the information exchange of transmission function and receiver function.
In the present embodiment by identifying subject thread type, in a manner of choosing the carrying out practically of intended recipient function, from And realize the determination of the thread running environment adapted to for intended recipient function itself;Simultaneously so that sending function can be into Determine a receiver function for being able to carry out follow-up distribution operation work(.
In addition, the embodiment of the present invention also proposes a kind of storage medium, disappearing based on thread is stored with the storage medium Processing routine is ceased, following operation is realized when the message processing program based on thread is executed by processor:
When detecting transmission function, the subject thread type for sending function is obtained;
Receiver function corresponding with the subject thread type is searched in current receiver function set, is connect what is found Function is received as intended recipient function;
Message distribution is carried out in the subject thread residing for the intended recipient function by the intended recipient function.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
Obtain the objective function parameters type of the transmission function;
The current receiver function set corresponding to according to the objective function parameters type search, described in mapping relations Mapping relations include function parameter type and the corresponding relation of receiver function set, and the receiver function set includes each reception letter Number.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to default class object;
The sample function parameter type according to corresponding to determining the sample reception function;
Using each sample receiver function of the sample function parameter type identical as sample reception function set, institute is established The corresponding relation of sample function parameter type and the sample reception function set is stated, the corresponding relation is added into described reflect Penetrate in relation.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
Obtain the reference information of the transmission function;
The default class object is generated according to the reference information.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
Class class objects are generated according to the class category informations;
Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to the class class objects.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
Identify the subject thread type;
When the subject thread type is main thread type, disappeared by the intended recipient function in main thread Breath distribution, the main thread type are corresponding with the main thread;
Or,
When the subject thread type is sub-line journey type, disappeared by the intended recipient function in sub-line journey Breath distribution, the sub-line journey type are corresponding with the sub-line journey.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
When the subject thread type is main thread type, pass through the intended recipient function call main thread Looper, so that the intended recipient function carries out message distribution in the main thread.
Further, following operation is also realized when the message processing program based on thread is executed by processor:
When the subject thread type is sub-line journey type, creates new thread and call the Looper of the new thread, So that the intended recipient function carries out message distribution in the new thread.
By finding receiver function corresponding with the subject thread type, the reception letter that will be found in the present embodiment Number is used as intended recipient function, and message distribution is carried out in the current thread by the intended recipient function, also just real Show and different executable receiver functions is determined based on different transmission functions, overcome nothing present in android system Method ensures to send the technical problem that preferable coupling is maintained between function and receiver function.Specifically, thread will be based on Type carries out the selection of receiver function so that the thread type of operation meets operation demand.
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
It should be noted that herein, term " comprising ", "comprising" or its any other variant are intended to non-row His property includes, so that process, method, article or system including a series of elements not only include those key elements, and And also include the other element being not expressly set out, or also include for this process, method, article or system institute inherently Key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that including this Other identical element also be present in the process of key element, method, article or system.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.Word first, second, with Can be title by these word explanations and third use does not indicate that any order.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on such understanding, technical scheme is substantially done to prior art in other words Going out the part of contribution can be embodied in the form of software product, and the computer software product is stored in a storage medium In (such as ROM/RAM, magnetic disc, CD), including some instructions to cause a station terminal equipment (can be mobile phone, computer, clothes Be engaged in device, air conditioner, or network equipment etc.) perform method described in each embodiment of the present invention.
The preferred embodiments of the present invention are these are only, are not intended to limit the scope of the invention, it is every to utilize this hair The equivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skills Art field, is included within the scope of the present invention.

Claims (10)

  1. A kind of 1. message treatment method based on thread, it is characterised in that the message treatment method based on thread include with Lower step:
    Smart machine obtains the subject thread type for sending function when detecting transmission function;
    Receiver function corresponding with the subject thread type, the reception letter that will be found are searched in current receiver function set Number is used as intended recipient function;
    Message distribution is carried out in the subject thread residing for the intended recipient function by the intended recipient function.
  2. 2. the message treatment method based on thread as claimed in claim 1, it is characterised in that the smart machine is detecting When sending function, after obtaining the subject thread type for sending function, the message treatment method based on thread also wraps Include:
    Obtain the objective function parameters type of the transmission function;
    Current receiver function set, the mapping corresponding to according to the objective function parameters type search in mapping relations Relation includes function parameter type and the corresponding relation of receiver function set, and the receiver function set includes each receiver function.
  3. 3. the message treatment method based on thread as claimed in claim 2, it is characterised in that the smart machine is detecting When sending function, before obtaining the objective function parameters type for sending function, the message treatment method based on thread Also include:
    Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to default class object;
    The sample function parameter type according to corresponding to determining the sample reception function;
    Using each sample receiver function of the sample function parameter type identical as sample reception function set, the sample is established This function parameter type and the corresponding relation of the sample reception function set, the corresponding relation is added into the mapping and closed In system.
  4. 4. the message treatment method based on thread as claimed in claim 3, it is characterised in that the reflection machine based on Java System is come before each sample receiver function according to corresponding to obtaining default class object, and the message treatment method based on thread also wraps Include:
    Obtain the reference information of the transmission function;
    The default class object is generated according to the reference information.
  5. 5. the message treatment method based on thread as claimed in claim 4, it is characterised in that the reference information is class Category information;
    Correspondingly, it is described that the default class object is generated according to the reference information, based on Java reflex mechanism come according to pre- If each sample receiver function corresponding to class object acquisition, is specifically included:
    Class class objects are generated according to the class category informations;
    Each sample receiver function corresponding to being obtained based on Java reflex mechanism according to the class class objects.
  6. 6. the message treatment method based on thread as any one of claim 1 to 5, it is characterised in that described to pass through The intended recipient function carries out message distribution in the subject thread residing for the intended recipient function, specifically includes:
    Identify the subject thread type;
    When the subject thread type is main thread type, message point is carried out in main thread by the intended recipient function Hair, the main thread type are corresponding with the main thread;
    Or,
    When the subject thread type is sub-line journey type, message point is carried out in sub-line journey by the intended recipient function Hair, the sub-line journey type are corresponding with the sub-line journey.
  7. 7. the message treatment method based on thread as claimed in claim 6, it is characterised in that described in the subject thread class When type is main thread type, message distribution is carried out in main thread by the intended recipient function, specifically included:
    When the subject thread type is main thread type, by the Looper of the intended recipient function call main thread, So that the intended recipient function carries out message distribution in the main thread.
  8. 8. the message treatment method based on thread as claimed in claim 6, it is characterised in that described in the subject thread class When type is sub-line journey type, message distribution is carried out in sub-line journey by the intended recipient function, specifically included:
    When the subject thread type is sub-line journey type, creates new thread and call the Looper of the new thread, so that The intended recipient function carries out message distribution in the new thread.
  9. 9. a kind of smart machine, it is characterised in that the smart machine includes:Memory, processor and it is stored in the storage On device and the message processing program based on thread that can run on the processor, the message processing program based on thread The step that the message treatment method based on thread as any one of claim 1 to 8 is realized during the computing device Suddenly.
  10. 10. a kind of storage medium, it is characterised in that the message processing program based on thread, institute are stored with the storage medium State when the message processing program based on thread is executed by processor realize as any one of claim 1 to 8 based on line The step of message treatment method of journey.
CN201711082986.1A 2017-11-06 2017-11-06 Thread-based message processing method, intelligent device and storage medium Active CN107818023B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711082986.1A CN107818023B (en) 2017-11-06 2017-11-06 Thread-based message processing method, intelligent device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711082986.1A CN107818023B (en) 2017-11-06 2017-11-06 Thread-based message processing method, intelligent device and storage medium

Publications (2)

Publication Number Publication Date
CN107818023A true CN107818023A (en) 2018-03-20
CN107818023B CN107818023B (en) 2021-06-15

Family

ID=61604865

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711082986.1A Active CN107818023B (en) 2017-11-06 2017-11-06 Thread-based message processing method, intelligent device and storage medium

Country Status (1)

Country Link
CN (1) CN107818023B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109005448A (en) * 2018-06-28 2018-12-14 武汉斗鱼网络科技有限公司 Barrage message distributing method, device, equipment and storage medium
CN109413502A (en) * 2018-09-29 2019-03-01 武汉斗鱼网络科技有限公司 Multithreading barrage message distributing method, device, equipment and storage medium
CN112363779A (en) * 2020-11-25 2021-02-12 王志平 Safety control method for dynamic link program
CN114546665A (en) * 2022-04-22 2022-05-27 恒生电子股份有限公司 Object processing method and system
WO2022155937A1 (en) * 2021-01-23 2022-07-28 王志平 Security control method for dynamic link program

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060044595A1 (en) * 2004-08-24 2006-03-02 Sharp Laboratories Of America Inc. Imaging job monitoring and pipelining
US8627335B2 (en) * 2006-11-13 2014-01-07 Oracle America, Inc. Method and apparatus for data space profiling of applications across a network
US20140189714A1 (en) * 2012-10-10 2014-07-03 Webtrends Inc. Methods and automated systems for testing, optimization, and analysis that preserve continuity in identities and status of users who access remote information from different contexts
WO2016103057A1 (en) * 2014-12-26 2016-06-30 Yandex Europe Ag Method and apparatus for processing an image on an electronic device
CN106407377A (en) * 2016-09-12 2017-02-15 北京百度网讯科技有限公司 Search method and device based on artificial intelligence
CN106598725A (en) * 2016-10-31 2017-04-26 武汉斗鱼网络科技有限公司 Android-based Handler memory leakage prevention device and method
CN106649036A (en) * 2016-11-24 2017-05-10 北京瑞星信息技术股份有限公司 Method and device for Linux network access monitoring
CN107015840A (en) * 2017-03-17 2017-08-04 南京南瑞继保电气有限公司 A kind of rapid implementation method of resolver and quick execution system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060044595A1 (en) * 2004-08-24 2006-03-02 Sharp Laboratories Of America Inc. Imaging job monitoring and pipelining
US8627335B2 (en) * 2006-11-13 2014-01-07 Oracle America, Inc. Method and apparatus for data space profiling of applications across a network
US20140189714A1 (en) * 2012-10-10 2014-07-03 Webtrends Inc. Methods and automated systems for testing, optimization, and analysis that preserve continuity in identities and status of users who access remote information from different contexts
WO2016103057A1 (en) * 2014-12-26 2016-06-30 Yandex Europe Ag Method and apparatus for processing an image on an electronic device
CN106407377A (en) * 2016-09-12 2017-02-15 北京百度网讯科技有限公司 Search method and device based on artificial intelligence
CN106598725A (en) * 2016-10-31 2017-04-26 武汉斗鱼网络科技有限公司 Android-based Handler memory leakage prevention device and method
CN106649036A (en) * 2016-11-24 2017-05-10 北京瑞星信息技术股份有限公司 Method and device for Linux network access monitoring
CN107015840A (en) * 2017-03-17 2017-08-04 南京南瑞继保电气有限公司 A kind of rapid implementation method of resolver and quick execution system

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
KYUNG SIK SEO ET AL: "Numerical and Experimental Characterization of Thread-Type Magnetic Core With Low Eddy Current Loss", 《IEEE TRANSACTIONS ON MAGNETICS》 *
MENG WANG ET AL: "Event Driven Web Video Summarization by Tag Localization and Key-Shot Identification", 《 IEEE TRANSACTIONS ON MULTIMEDIA》 *
传智播客高教产品研发部: "《Android移动应用基础教程》", 31 January 2015, 中国铁道出版社 *
张伟: "《Java程序详解》", 31 March 2014, 东南大学出版社 *
纪晓阳: "线程在Android开发中的应用", 《软件》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109005448A (en) * 2018-06-28 2018-12-14 武汉斗鱼网络科技有限公司 Barrage message distributing method, device, equipment and storage medium
CN109413502A (en) * 2018-09-29 2019-03-01 武汉斗鱼网络科技有限公司 Multithreading barrage message distributing method, device, equipment and storage medium
CN109413502B (en) * 2018-09-29 2021-04-27 武汉斗鱼网络科技有限公司 Multithreading barrage message distribution method, device, equipment and storage medium
CN112363779A (en) * 2020-11-25 2021-02-12 王志平 Safety control method for dynamic link program
WO2022155937A1 (en) * 2021-01-23 2022-07-28 王志平 Security control method for dynamic link program
CN114546665A (en) * 2022-04-22 2022-05-27 恒生电子股份有限公司 Object processing method and system
CN114546665B (en) * 2022-04-22 2022-08-05 恒生电子股份有限公司 Object processing method and system

Also Published As

Publication number Publication date
CN107818023B (en) 2021-06-15

Similar Documents

Publication Publication Date Title
CN107818023A (en) Thread-based message processing method, intelligent device and storage medium
US11487800B2 (en) Method and apparatus for processing information of a terminal
US20160255093A1 (en) Methods, apparatuses and computer program products for automated learning of data models
CN104809589A (en) Order processing method and device
CN108023808A (en) message distributing method and device in application program
CN103605502B (en) Form page display method and server
CN104598513A (en) Data flow control method and system based on webpage frame
CN110058999A (en) Electronic device, application exception localization method and storage medium
CN106886544A (en) A kind of data processing method and device
CN110177053A (en) A kind of smart message sending method and device
CN109711396A (en) Generation method, device, equipment and the readable storage medium storing program for executing of OCR training sample
CN108900627B (en) Network request method, terminal device and storage medium
CN105376719A (en) Information pushing method and device
CN106331767A (en) Data error correcting processing method, terminal, server, and system
CN115033317B (en) Method and device for processing bullet frame, electronic equipment and readable storage medium
CN111552463A (en) Page jump method and device, computer equipment and storage medium
US20210173553A1 (en) Slider for content selection in user interface
US20210142803A1 (en) Information processing system, method, device and equipment
CN112840305B (en) Font switching method and related product
CN109150720A (en) Business chain message forwarding method, device, equipment and computer readable storage medium
CN115600980A (en) Method and device for sending message, electronic equipment and storage medium
CN104836892A (en) Information display method, information display device and information display terminal
CN110597492B (en) Module calling method and related products
CN105391619A (en) Method for ensuring information display sequence and electronic equipment
CN108596270A (en) Picture control methods, device, equipment and computer readable storage medium

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200214

Address after: 201, room 518000, building A, No. 1, front Bay Road, Qianhai Shenzhen Guangdong Shenzhen Hong Kong cooperation zone (Qianhai business secretary)

Applicant after: Shenzhen leynew Network Media Co Ltd

Address before: 518000 Guangdong city of Shenzhen province Qianhai Shenzhen Hong Kong cooperation zone before Bay Road No. 1 building 201 room A (located in Shenzhen Qianhai business secretary Co. Ltd.)

Applicant before: Shenzhen leynew Mdt InfoTech Ltd

GR01 Patent grant
GR01 Patent grant