-
Process first let’s look at the definition of a process: ** a process is a unit of execution. On PC and mobile devices, it is a program or application. ** Thread is the smallest unit of CPU scheduling, and thread is a limited system resource. A process can contain multiple threads, so the process and thread are contained and included. When an application component is started and the application does not run any other components, The Android system uses a single thread of execution to start a new Linux process for the application. By default, all components of the same application run in the same process and thread (called the “main” thread).
-
Open multi-process multi-process benefits: 1, increase the available memory of the application, Android has a limit on the maximum memory of the application, open multi-process can apply for more than one piece of memory, the application of large memory consumption module, you can consider opening a new process. 2. Multiple processes can prevent the entire program from crashing. If a new process crashes, it will be returned to the main process instead of causing the entire program to crash. If the client and server are not the same application, the default is two processes. If multiple processes are enabled within an application, the four components in the Androidmanifest.xml file,,, and all support the Android: Process attribute to enable multiple processes. By setting this property, you can have each component run in its own process, or some components share a process and others do not. The Android default process name is the package name. Android :process=” xxx.XXX.XXXX. remote” complete named way, belongs to the global process, other applications through the ShareUID way and it can run in the same process. Android: Process =”:remote”, “: “indicates that the package name must be added before the current process name. A process name starting with “:” belongs to a private process and is inaccessible to other applications.
-
Problems with multiple processes (1). Static members and singletons completely fail (2). The thread synchronization mechanism completely fails (3). The reliability of SharedPreference deteriorates (4). The Application will be created multiple times
-
IPC is short for Inter-process Communication. It refers to the Process of data exchange between two processes. There are several ways to communicate between processes: IntEnts pass data, file sharing, Messenger, AIDL, ContentProvider, Socket, etc. An Intent can only deliver a simple object. The object must implement the serialization of the Pacelable interface. 2, Messenger based on Message to implement inter-process communication, the server is serial execution of client requests, the underlying implementation is AIDL, see: inter-process communication Messenger; 3. Allow clients of different applications to access the service in IPC mode, and can handle multi-threading on the server side. For details, see AIDL for interprocess communication. 4. Interprocess communication can also be implemented by inheriting Binder classes.