Hello,
i use a ScheduledThreadPoolExecutor combined with a ThreadFactory,
their all combined should
cause an unchaught Exception to be logged so that i can see what
happening if any thread is dying in the ThreadPool:
threadPool = new ScheduledThreadPoolExecutor(poolSize, new
ThreadFactory());
My ThreadFactory, also sets a UncaughtExceptionHandler :
public Thread newThread(final Runnable r)
{
final Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler(new ThreadLogger());
final int counter = count.getAndIncrement();
final String name = threadName + counter;
thread.setName(threadName + counter);
if (Logging.isLoggingEnabled())
{
Log.d(LOG_TAG, "Thread created :" + name);
}
return thread;
}
The ThreadLogger :
public final class ThreadLogger implements
Thread.UncaughtExceptionHandler
{
private final static String LOG_TAG =
ThreadLogger.class.getSimpleName();
/*
* (non-Javadoc)
*
* @see
*
java.lang.Thread.UncaughtExceptionHandler#uncaughtException(java.lang
* .Thread, java.lang.Throwable)
*/
@Override
public void uncaughtException(final Thread _thread, final Throwable
_ex)
{
Log.e(LOG_TAG, "uncaughtException, Name" + _thread.getName() + "
prio " + _thread.getPriority(), _ex);
}
But when a RuntimeException is thrown the Handler never get called. Is
this a Bug ?
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