I have noticed that if my SimpleApplication based app crashes, it doesn’t removed from the task manager (Windows) which means the process still exists.
It happened recently when I have added some background threads (thread pool) for loading assets.
My guess (maybe I’m wrong, not sure about it) is that the threads are not cleaned properly due to the crash so it prevents the process from shutting down.
My question is how / where to perform the cleanup code in SimpleApplication so it will handle app crashes as well…
I’m not sure what do you mean by “sleep forever”. The threads are contained & maintained using ExecutorService:
private ExecutorService executorService = null;
Whenever needed, I fetch a thread from the pool and use it for asset loading.
One more option - I know that SimpleApplication shows a modal dialog on app crash, maybe it pops up but stays invisible (for some reason) preventing the process from shutting down…
Then you can probably tweak the configuration of your thread pool to work around it. Since you never call shutdown on it. It might just idle in the background forever. So unless you find a way to hook to a crash… You can tweak it to have 0 core threads and cool down time somewhere reasonable…
But also when looking at the code. I’m pretty sure you might be able to deal with this by overriding handleError on your SimpleApplication.