I have an Android Service that is started by my application and does some things in a threadPool using 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?