Create a thread in the activity and stop that activity, then what will happen to that thread, will it be alive or dead?
it will be alive, but its priority will be least compared to thread in a service.
thread created by activity will be killed immediately after activity lost its focus or life time.
it will be alive for some time, and then garbage collected.
it will be alive for ever, it wastes memory.
once a thread is created, it will run independently of who has created until the work given to that thread is finished. but in case of low memory scenarios a thread created by activity and which is running in the background will have more susceptibility of being killed by android system. More worse is android can not recreate the thread which was killed because of low memory. but if that thread was in service, then chances of getting killed by android due to low memory may be less than previous situation. even if android system kills the thread, again it will start the service when memory resources are available and service can re-initiate that killed thread.
Back To Top