When Android kills an app, can a function be stopped halfway?

后端 未结 7 2125
青春惊慌失措
青春惊慌失措 2020-12-10 03:30

I am wondering: when an app is to be killed, does Android wait for the currently running function to return, or does Android stop it before it ends by itself?

7条回答
  •  醉酒成梦
    2020-12-10 04:17

    Each android app runs on a separate Dalvik VM. and when android kills that app , it destroys that VM instance. and doesn't care for the threads you are using or what are they doing , you can easily test that , by creating a tcp server socket which will block until a client connects and then kill the app, nothing happens, no interrupt exception raise or anything because the VM instance itself get killed.

提交回复
热议问题