/**
   * Send @param t and any exception wrapped by @param r to the default uncaught exception handler,
   * or log them if none such is set up
   */
  public static void logExceptionsAfterExecute(Runnable r, Throwable t) {
    Throwable hiddenThrowable = extractThrowable(r);
    if (hiddenThrowable != null) handleOrLog(hiddenThrowable);

    // ThreadPoolExecutor will re-throw exceptions thrown by its Task (which
    // will be seen by
    // the default uncaught exception handler) so we only need to do
    // anything if that handler
    // isn't set up yet.
    if (t != null && Thread.getDefaultUncaughtExceptionHandler() == null) handleOrLog(t);
  }
 /** Send @param t to the default uncaught exception handler, or log it if none such is set up */
 public static void handleOrLog(Throwable t) {
   if (Thread.getDefaultUncaughtExceptionHandler() == null)
     logger.error("Error in ThreadPoolExecutor", t);
   else Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), t);
 }