简体   繁体   English

Dalvik / JVM如何处理多处理的应用程序

[英]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? 我想知道Dalvik实例是按应用程序还是按进程分叉的,也就是说,如果我的应用程序具有多个进程,那么我是否也有多个Dalvik实例? 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? 因此,当我单击一个按钮时,是Dalvik的另一个实例被派生了,而字节代码是否被新实例化的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? 假设我回到第一个活动,运行时如何确定现在第一个Dalvik应该解释字节码?

Activities are not processes. 活动不是过程。 A single process / app can have many Activity instances, each of which are essentially just Java objects. 单个进程/应用程序可以具有许多Activity实例,每个实例基本上都是Java对象。 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. 进程切换确实发生时,就像在任何其他基于Unix的操作系统中一样,在操作系统级别进行处理。 Processes are running concurrently and are given more or less time on the processor as the OS sees fit. 进程可以同时运行,并且在OS认为合适的情况下,可以在处理器上获得更多或更少的时间。

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. 进行“ 管理活动生命周期后台作业最佳实践”培训可能会有所帮助,它将为您提供更多的背景知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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