multithreading - Android: how to guarantee destruction of a private thread? -


this follow-on earlier post today. if create persistent thread (eg, network activity every 15 seconds), there way can guarantee destruction when app terminates?

i suppose question can generalized: when android app dies, there way can guarantee body of user- or application-logic execute?

on non-trivial os, process termination begins when thread of process requests termination, or process appropriate permissions , privileges requests termination.

one of first steps in process termination remove execution threads, no matter state happen in. essential prevent threads allocating further resouces process , prevent them actively using rsources allocated. threads not running have state changed 'never run again'. threads running on cores stopped hardware-interrupt of cores running them. once threads stopped, kernel can start releasing resources fd's, memory-segments etc.

a out-of-process temination cannot allowed run kind of 'ontermination' code belongs process. in such code, simple infinite loop prevent process termination , tie core indefinitely. other possibilities malicious action possible.

this can result in problems resources shared other processes or systems. 1 way of getting round design app 'left over' connections, partially-written files, shared memory stuff, whatever, cleaned on process startup, instead of process shutdown.

systems should designed not absolutey depend upon 'clean' shutdowns , can recover events critical segfaults, out-of-process terminations, power failures, coffee-spillage , frothy beer-cans.

your app-lifetime threads terminated upon out-of-process termination. can detach them terminated upon in-process shutdown, (and should design make termination safe can without relying on 'ontermination' signals/handlers/whatever, since exploding beer cans happen).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -