Android multi process data summary

Consider the past you shall know the future

There are many articles about multi process on the Internet, but they are basically discussing very deep things, which needs to be specially studied. I'm here to be lazy (application level). What I record is my understanding of multi process, which is convenient for me to be lazy when I use it in the future. If there is any mistake, please give me advice. Thank you very much.

To talk about the process, let's answer the following questions:

1. What is a thread?

A thread is a flow control executed separately in a program.

2. What is multithreading?

Multithreading is the execution of multiple flow controls in a single program. The function is to maximize the use of CPU resources.

3. What is a process?

It generally refers to an execution unit, that is, an application (an application in Android).

4. The relationship between threads and processes?

A process can have multiple threads, and processes and threads are included and included.

5. Why use multiple processes?

1. The memory allocated by a single process is not enough and more memory is required. 2. You need to run a separate component. 3. Do some invisible activities, such as (a - > heartbeat - > b, if B does not start, start B. B - > heartbeat - > A, if a does not start, start a. in short, double daemons are used to prevent users from killing.)

6. How to start multiple processes?

AndroidManifest. Set Android: process = ": remote" in XML

Start this service in activity

7. What is a colon in ": remote"?

It is not a ghost. Android: process means what ghost process this component runs in, that is, the process name. Use: means that this process is private to the application that starts it. It's similar to omitting the package name when we register an activity. If our package name is com example. Whitelining, the name of the Android: process = ": remote" process is "com. Example. Whitelining: remote".

8. What is the difference between a private process and a global process?

I also want to know% > <% If someone knows, please advise Ye Yuji Beida. The reply is, e belt: indicates that it is the private process of the current application. Components of other applications cannot run in the same process with it. For the global process, other applications can be in the same process with it through shareuid. Applications with the same uid mask can share data and access each other's private data (the chairman's book is explained in the multi process section)

9. What should be paid attention to in multi process?

1. Every time you start multiple processes, the application will be executed again, so if you do a lot of initialization work in the application, you need to judge which process started the application.

method:

2. Multiple processes will invalidate the singleton mode because the memory of the two threads is isolated.

10. What else do you want to know?

Go and see the source code. You will die and live. If you are not dead after reading it, please tell me the difference between private process and global process. I will offer my knees for one year~

Through this article, I hope to master the information of Android multithreading. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>