Stopping a service once it has finished it's work
I have an Android Service that is started by my application and does some things in a threadPool using开发者_Python百科 Executors.newCachedThreadPool()
Once it has finished doing it's work I would like the service to stopSelf()
, how can I get the service to determine when it is no longer needed (ie, there are no more Threads executing) so that it can shut itself down automatically?
Do it the other way: the last Runnable
should shut the Service
upon completion.
精彩评论