Search code examples
androidmultithreadingexecutor

Will threads of executor automatically exit after an Android app being closed


I'm implement a simple network framework that running upon the executor framework. Since I think it's unreliable to rely the client to shut down my NetworkOperator, I had provided a app-shared singleton for the client.

And then, what will happen if the instance of Application being destroyed(that is, the user close our app). Will the thread of executor framework being destroyed? (I know that in a C app, if the main function returned, the process will exit. Is the main thread of Android APP also has a main? If it does, will this behavior be changed as Android will cached the closed app?)


Solution

  • yes. you are correct.

    The main thread of the android app a main and it is the UI thread.

    If you want to do some asynchronous task wven when your app is killed, then use a thread within a started service instead of simply using thread/asyncTask