简体   繁体   中英

How does Dalvik/JVM handle multi processed apps

I'm wondering if Dalvik instance is being forked per application or per process, that's to say if I've got an app with multiple processes do I also have multiple Dalvik instances? And how does actually multi processing happen?

Let me describe a simple scenario:

I start an app which starts an activity which runs in the first process, then I click a button which spawns another activity which starts to run in a different process.

So when I click a button is another instance of Dalvik being forked, and is the byte code being interpreted with the newly instantiated Dalvik? And if its true, how does the process switching happen. Say if I go back to the first activity how does the runtime determine that now the first Dalvik should interpret the byte code?

Activities are not processes. A single process / app can have many Activity instances, each of which are essentially just Java objects. Clicking a button that launches a new activity is therefore more analogous to creating a new instance than launching a new process.

Process switching, when it does occur, is handled at the OS level just like any other Unix-based OS. Processes are running concurrently and are given more or less time on the processor as the OS sees fit.

It might be helpful to go through the Managing the Activity Lifecycle and Best Practices for Background Jobs training, which will give you more background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM