making executors more debuggable
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Mogwee Executors, making executors more debuggable

Mogwee Executors contains a few classes designed to replace the executors built in to Java. Java's standard executors silently fail if an uncaught RuntimeException is thrown. Even worse, a ScheduledExecutorService will silently cancel all future executions of a task that has such an exception.

While there are many simpler ways which seem like they should work (e.g., Thread.UncaughtExceptionHandler or creating a ThreadFactory that wraps a Runnable within another Runnable that's got a try…catch), they don't, mostly due to ScheduledExecutorService already having wrapped the Runnable before anything else can. If you think you have a simpler or better way of producing the same behavior, the TestExecutors unit test should provide a quick and easy way of checking whether the approach actually works.

In addition to exception logging, Mogwee Executors also ensures the threads created by executors it returns have some base name you specified when creating the executor. This is always a good idea and can be of great help when analyzing thread dumps.

Maven Info



Just use com.mogwee.executors.Executors in the same way you would use java.util.concurrent.Executors.

Mogwee Executors relies on SLF4J for logging. This means you must configure SLF4J to use your logging framework. For example, to log to System.err, you would add the following to your pom.xml dependencies:


If, on the other hand, you wanted to use Log4J for all your logging, you would instead add the following to your pom.xml dependencies:


See for more details and options.

Version History


  • Fix Future returned by submit(Runnable) returning null on failure instead of re-throwing exception.


  • Add constructor to FailsafeScheduledExecutor that allows custom ThreadFactory to be used (by request of tomdz).


  • Use SLF4J instead of Mogwee Logging.

License (see COPYING file for full license)

Copyright 2011 Ning, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.