Hello,
when stop my Service i may have several Tasks in a Threadpool, some
may take some time. Is there any Documentation available how long the
onDestroy method is allowed to run without risk an ANR Dialog ?
As an example, theres what i played with:
@Override
public void onDestroy()
{
try
{
Log.d(LOG_TAG, "Service#onDestroy");
//
if (threadPool != null)
{
threadPool.shutdown();
}
try
{
Log.d(LOG_TAG, "Service#onDestroy sleeps");
Thread.sleep(60 * 1000L);
Log.d(LOG_TAG, "Service#onDestroy sleep ends");
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (final SecurityException e)
{
Log.e(LOG_TAG, "shutdown failed", e);
}
finally
{
super.onDestroy();
}
In some circumstances it can take lots of time before the task is
completed.
I can monitor that by using ThreadPoolExcecutor#awaitTermination but i
need a safe value for it.
best regards,
Jens
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.