In the onStartCommand()
method of my service, I start a long-running thread.
The service is started in my MainActivity
's onCreate()
.
When my application quit (the time Main Activity closed by user), I stop the service. But I want to ensure that the thread mentioned before has been killed, or I have to stop the thread before/after that.
So will all threads started in a service be killed automatically when the service stopped?
I have just checked this by logging the thread's state in my service's
onDestroy()
. The thread remains alive after my service stopped.