开发者

When does the activity object really get killed after calling finish()?

I created a thread in my activity, and that thread will print out the value of my instance variables in m开发者_开发问答y activity after running for about 10 seconds. I pressed the back key to destroy my activity before the thread prints out the values, and when the thread reaches that line of code, it can still print out the values correctly. That means even though the activity is finished, the java object of the activity is still there. Will the object always be there? Or it is just waiting to be GCed? Or it will be killed only when Android needs memory?


See this question: your Thread will not be garbage collected even if the activity is destroyed. You need to specifically request your Thread to terminate in your onFinish() function. Then either let it kill itself or do a join() in order to wait for it to actually terminate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜