0

If an app is brought to the background what happens to the UI Thread which was running this app?

Will it sleep or get killed?

When the app is back to foreground will the same thread be notified or a new thread will created and associated with the app instance?

2 Answers 2

1

I don't know specifically, but you should always program with the possibility that your Activity may be killed at any time that it is not in the foreground. Whether that involves killing the thread every time it enters the background, or causing the thread to sleep and then killing it if the Activity is killed, I don't know. In any case, you must assume it can and will happen, and program accordingly.

Sign up to request clarification or add additional context in comments.

Comments

0

It depends on the memory situation. When your application goes into the background, it generally stays running initially. Android does not sleep your thread. It is up to you to stop updating your UI and performing calculations in on onPause.

However in low memory situations Android might kill application when it's the background (especially if you haven't been nice and are using up a load of resources). For this reason you should always save any persistant data in onPause.

1 Comment

If app A is brought to the bckgrnd and it intially keeps running then as you say the THREAD associated with A will be running? If I launch app B then will a new thread be created and associated with B or the same UI thread will be used for both A and B depending which app is in foregrnd?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.