Android-活动结束后,线程会如何处理? [英] Android - What happens to Threads when a Activity finishes?

查看:162
本文介绍了Android-活动结束后,线程会如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Activity,它启动了Thread做一些工作.如果用户按下后退"按钮,或者UI线程对该线程调用finish(),会发生什么?

I have an Activity, which starts a Thread to do some work. What happens if the user presses the Back button, or the UI thread calls finish() to the thread?

活动将在销毁活动之前等待线程进入finish()吗?

Will the activity wait for the thread to finish() before the activity is destroyed?

活动被破坏后,线程是否完成其工作?

Does the thread complete its work after the activity gets destroyed?

推荐答案

线程将完成其工作,但是您不能对活动使用任何回调.

Thread will do its work, but you can't use any callbacks to your activity.

这篇关于Android-活动结束后,线程会如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆