Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method and a system for multiprocess interactive processing, aiming at the above-mentioned defects in the prior art. The invention increases the smoothness of App use and improves the system efficiency.
The technical scheme adopted by the invention for solving the technical problem is as follows:
a multi-process interactive processing method comprises the following steps:
A. setting a resource-occupied thread corresponding to an application as a thread needing thread separation during running according to the resource occupation degree of the thread during running in the running process of the application in advance;
B. when the thread of the application needs to execute the running task, detecting whether the thread which needs to execute the running task at present is a resource-occupied thread which needs thread separation;
C. separating the thread which needs to execute the running task from the main process as an independent process for calling the APP to form a sub-process separated from the main process, wherein the sub-process is a resource-occupying process;
D. when the corresponding application is started, the main process and the sub-process corresponding to the application are controlled to be started in parallel, corresponding running tasks are executed, and when the application is not closed, the sub-process can be controlled to run independently in the background, so that silent upgrade service is realized.
The multi-process interactive processing method comprises the step of enabling the resource occupying thread to comprise a downloading thread.
The multi-process interactive processing method further comprises the following steps:
e1, when starting downloading, judging whether AIDL binding service is bound;
e2, when the AIDL binding service is bound, modifying the downloading state through the sub-process, starting the downloading thread through the sub-process, and entering the step E3;
e3, informing the main process of updating the downloading progress, and entering the step E4;
e4, when the download is completed, notifying the host process to execute the subsequent logic, and entering step E5;
e5, the main process removes the AIDL binding service of the sub-process.
According to the multi-process interactive processing method, the AIDL is an android interface definition language.
According to the multi-process interactive processing method, the AIDL binding service is a process communicator intelligence of android, and two processes need to be bound once every time the two processes communicate.
A multi-process interactive processing system, comprising:
the system comprises a presetting module, a thread separation module and a resource separation module, wherein the presetting module is used for presetting a resource occupying thread corresponding to an application as a thread needing thread separation during running according to the resource occupying degree during the running of the thread during the running of the application;
a detection module, configured to detect whether a thread currently requiring execution of a running task is a resource-occupied thread requiring thread separation when the thread of an application needs execution of the running task
The thread separation module is used for separating the thread which needs to execute the running task from the main process as an independent process for calling the APP application to form a sub-process separated from the main process, wherein the sub-process is a resource-occupying process;
and the multi-process control module is used for controlling the main process and the sub-process corresponding to the application to be started in parallel when the corresponding application is started, executing corresponding running tasks, and controlling the sub-process to independently run at the background when the application is not closed so as to realize silent upgrade service.
The multi-process interactive processing system is characterized in that the resource occupying thread comprises a downloading thread.
The multi-process interactive processing system further comprises the following steps:
the binding judging module is used for judging whether the AIDL binding service is bound when the downloading is started;
the sub-thread control module is used for modifying the downloading state through the sub-process and starting a downloading thread through the sub-process when the AIDL binding service is bound;
the notification module is used for notifying the main process of updating the downloading progress;
the download completion control module is used for informing the main process to execute subsequent logic when the download is completed;
and the binding removing module is used for controlling the main process to remove AIDL binding service of the sub-process.
The multi-process interactive processing system is characterized in that the AIDL is an android interface definition language.
The multi-process interactive processing system is characterized in that the AIDL binding service is an android process communicator, and two processes need to be bound once every time the two processes communicate.
According to the multi-process interactive processing method and system provided by the invention, in order to enhance user experience and increase the use fluency of the App, a certain thread can be used for a long time and multiple frequencies in the running process of the App. For example, the App needs to constantly start a download thread to execute a download task, and the thread has particularly good resources. The thread can be separated and used as an independent process for calling by the App, so that the smoothness of the App can be greatly improved, and the process can be executed in the background. Even if the process crashes, the influence on the main process is limited, and the stability of the application is improved.
For example, the invention separates the downloading thread, so that the downloading thread becomes a sub-process and a main process which are started in parallel. As a system application, under the condition that an application market is not closed, the sub-process is protected, the downloading task can be executed in real time at the background, silent upgrade service can be realized, the use smoothness of App is increased, the system efficiency is improved, and the energy consumption is reduced.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer and clearer, the multi-process interactive processing method and system provided by the present invention are further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a multi-process interactive processing method according to a preferred embodiment of the present invention. As shown in fig. 1, a multi-process interactive processing method according to an embodiment of the present invention includes the following steps:
and S100, setting a resource-occupied thread corresponding to the application as a thread needing thread separation during running according to the resource occupation degree of the thread during running in the running process of the application.
In the embodiment of the invention, a resource-occupied thread corresponding to an application needs to be set as a thread needing thread separation during running according to the resource occupation degree of the thread during running in the running process of the application; for example, the App needs to always start a download thread to perform a download task, and the thread is particularly good resources. The invention can set the resource-occupied thread corresponding to the application as the thread needing thread separation when the application runs, namely, the thread is separated when the thread runs and is used as an independent process for calling by the App.
Step S200, when the thread of the application needs to execute the running task, detecting whether the thread needing to execute the running task is a resource-occupied thread needing thread separation.
In other words, in the present invention, when the thread of the application needs to execute the running task, it is detected whether the thread that needs to execute the running task is a resource-occupied thread that needs thread separation. For example, whether it is a downloading thread of the resource thread. In the embodiment of the present invention, the resource occupying thread includes a downloading thread, but may also be other threads that occupy resources relatively, such as an antivirus thread.
And step S300, if the thread which needs to execute the running task currently is a resource-occupied thread which needs thread separation, separating the thread which needs to execute the running task currently from the main process and using the thread as an independent process for APP application calling to form a sub-process separated from the main process, wherein the sub-process is a resource-occupied process.
In the embodiment of the invention, the thread which needs to execute the running task at present is the resource-occupied thread which needs thread separation, the thread which needs to execute the running task at present is separated from the main process and is used as an independent process for APP application calling, and a sub-process separated from the main process is formed, wherein the sub-process is the resource-occupied process. For example, in order to enhance the operating efficiency, the smoothness of the App is increased, and a certain thread is used for a long time and multiple frequencies in the running process of the App. For example, the App needs to constantly start a download thread to execute a download task, and the thread has particularly good resources. The thread can be separated and used as an independent process for calling by the App, so that the smoothness of the App can be greatly improved, and the process can be executed in the background. Even if the process crashes, the influence on the main process is limited, and the stability of the application is improved.
And S400, when the corresponding application is started, controlling the main process and the sub-process corresponding to the application to be started in parallel, executing the corresponding running task, and when the application is not closed, controlling the sub-process to independently run at the background to realize the silent upgrade service.
In the embodiment of the invention, for example, the downloading thread is separated to be started in parallel as a sub-process and a main process. As a system application, under the condition that the application market is not closed, the sub-process can be protected, the downloading task can be executed in real time at the background, and the silent upgrade service can be realized
In a further embodiment, the multi-process interactive processing method according to the present invention further includes the following steps:
s1, when starting downloading, judging whether the AIDL binding service is bound;
and the AIDL is an android interface definition language. The AIDL binding service is android process communicator intelligence, and two processes need to be bound once every time the two processes communicate.
S2, when the AIDL binding service is bound, modifying the downloading state through the sub-process, starting the downloading thread through the sub-process, and entering the step S3;
s3, informing the main process of updating the downloading progress, and entering the step S4;
s4, when the downloading is finished, the main process is informed to execute the subsequent logic, and the step S5 is carried out;
s5, the main process removes the AIDL binding service of the sub-process.
Wherein the AIDL binding service is explained in detail as follows:
AIDL: android Interface Definition Language, Android Interface Definition Language. Memory cannot be shared among processes in the Android system, and therefore, some mechanisms need to be provided for data communication among different processes. In order to enable other applications to access the service provided by the application, the Android system is implemented in a Remote Procedure Call (RPC) mode. As with many other RPC-based solutions, Android uses an Interface Definition Language (IDL) to expose interfaces to services. It is known that 3 of the 4 Android application components (Activity, broadcastirever, ContentProvider) can perform cross-process access, and the other Android application component Service can also perform cross-process access. Therefore, such a service that can be accessed across processes may be referred to as an aidl (android Interface definitionslangue) service. The establishment of the AIDL service is more complicated than the establishment of the ordinary service, and the specific steps are as follows: (1) establishing a file with an extension name aidl in a Java package directory of Eclipse Android engineering. The syntax of this file is similar to Java code but slightly different. (2) if the content of the aidl file is correct, the ADT will automatically generate a Java interface file (, Java). And (3) establishing a Service class (Service subclass). And (4) realizing the Java interface generated by the aidl file. And (5) configuring the AIDL service in an android Manifest xml file, wherein the attribute value of the name in the < action > tag is the ID of the service to be referred by the client, namely the parameter value of the Intent class.
It should be noted that threads and processes are different concepts. A process may contain multiple (sub-) threads inside. The scope of the process is larger and the thread is smaller. The general structure in a program is a main process (a process) and a plurality of sub-threads.
The invention separates the download thread in the main process as an independent process (subprocess) for the main process to call through the inter-process communication protocol. The method has the advantages that not only is the efficiency improved, but also other processes (generally referred to as other apps) can call the downloading process in the same way.
Therefore, the multi-process interactive processing method provided by the invention increases the use smoothness of App and improves the system efficiency
Based on the above method embodiment, the present invention further provides a multiprocess interactive processing system, as shown in fig. 3, the system includes:
the presetting module 210 is configured to set a resource-occupied thread corresponding to an application as a thread requiring thread separation during running in advance according to a resource occupation degree during running of the thread during running of the application; as described above.
The detecting module 220 is configured to detect whether a thread that needs to execute an operation task is a resource-occupied thread that needs thread separation when the thread of the application needs to execute the operation task; as described above.
The thread separation module 230 is configured to separate a thread, which needs to execute a running task currently, from a main process if the thread, which needs to execute the running task currently, is a resource-occupied thread, which needs to perform thread separation, and use the thread as an independent process for the APP application to call, so as to form a sub-process separated from the main process, where the sub-process is a resource-occupied process; as described above.
The multi-process control module 240 is configured to control the main process and the sub-process corresponding to the application to be started in parallel when the corresponding application is started, execute a corresponding running task, and control the sub-process to run independently in the background when the application is not closed, so as to implement a silent upgrade service; as described above.
Further, the multi-process interactive processing system, wherein the resource occupying thread comprises a downloading thread.
Further, the multi-process interactive processing system further comprises the following steps:
the binding judging module is used for judging whether the AIDL binding service is bound when the downloading is started; as described above.
The sub-thread control module is used for modifying the downloading state through the sub-process and starting a downloading thread through the sub-process when the AIDL binding service is bound; as described above.
The notification module is used for notifying the main process of updating the downloading progress; as described above.
The download completion control module is used for informing the main process to execute subsequent logic when the download is completed; as described above.
The binding removing module is used for controlling the main process to remove AIDL binding service of the sub-process; as described above.
The multi-process interactive processing system is characterized in that the AIDL is an android interface definition language.
The multi-process interactive processing system is characterized in that the AIDL binding service is a process communication machine intelligence of an android, and two processes need to be bound once every time the two processes communicate; as described above.
In summary, in the multi-process interactive processing method and system provided by the invention, in order to enhance user experience and increase the smoothness of application of the App, a certain thread is used for a long time and multiple frequencies in the running process of the App. For example, the App needs to constantly start a download thread to execute a download task, and the thread has particularly good resources. The thread can be separated and used as an independent process for calling by the App, so that the smoothness of the App can be greatly improved, and the process can be executed in the background. Even if the process crashes, the influence on the main process is limited, and the stability of the application is improved.
For example, the invention separates the downloading thread, so that the downloading thread becomes a sub-process and a main process which are started in parallel. As a system application, under the condition that an application market is not closed, the sub-process is protected, the downloading task can be executed in real time at the background, silent upgrade service can be realized, the use smoothness of App is increased, the system efficiency is improved, and the energy consumption is reduced.
Of course, it will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by a computer program instructing relevant hardware (such as a processor, a controller, etc.), and the program may be stored in a computer readable storage medium, and when executed, the program may include the processes of the above method embodiments. The storage medium may be a memory, a magnetic disk, an optical disk, etc.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.