Skip to content Skip to sidebar Skip to footer

Android Scheduledthreadpoolexecutor Cause: Null

I'm tearing my hair out with this one! I'm a newbie to Android so I'm sure it's something super obvious. I'm getting a ScheduledThreadPoolExecutor exception where cause: null All I

Solution 1:

You cannot 'recycle' an ExecutorService. Once you have invoked shutdown(), attempting to schedule any task will cause a rejection, and in your case the rejection policy is to throw RejectedExecutionException.

If you follow your stacktrace, you can see in ScheduledThreadPoolExecutor:

/**
 * Specialized variant of ThreadPoolExecutor.execute for delayed tasks.
 */
private void delayedExecute(Runnable command) {
    if (isShutdown()) {
        reject(command);
        return;
    }
    // ...
}

Keeping your executor service as an instance variable is not going to work for you here: once it's been shutdown, it can't be used again.

Post a Comment for "Android Scheduledthreadpoolexecutor Cause: Null"