Does the thread die when activity is complete?

If I started the background thread, what happens if the action that starts with the finishes () before the thread ends. Will the stream be completed or will it survive?

new Thread(new Runnable() { public void run() { while (mProgressStatus > 0) { // Update the progress bar mHandler.post(new Runnable() { public void run() { progressbar.setProgress(mProgressStatus); } }); } } }).start(); 
+4
source share
2 answers

Threads run from parents. Thread dies when it returns from Thread.run () back to the JVM in normal mode or due to an uncaught exception.

0
source

For what you know, your thread / application can die at any time, at any time, the phone falls to the ground and the battery is turned off, and the last thing you know is the phone that it turned off in the fastest way.

The Android life cycle and its management are complex, and there is no real answer, because on Google, commenting on such things, they really like the word "automagic", so they certainly do not give out any internal details about this, at least not in " plain old English. "

There is the first Google IO about Android that talks about it, you can go back to YouTube and find Google life talk about the Android life cycle if you want more information about it.

In any case, Android does not give you absolutely nothing about how and for how long your application will work, and you have at least variables: what the OS does (Android) and what the user does, and these 2 things can even be mixed. when a user enters the life information of your application that Android should process.

-2
source

All Articles