Skip to content

Instantly share code, notes, and snippets.

@NikolayGorshkov
Created October 12, 2018 16:50
Show Gist options
  • Save NikolayGorshkov/40142d6cebfd498bb8c73a4ef85dd81f to your computer and use it in GitHub Desktop.
Save NikolayGorshkov/40142d6cebfd498bb8c73a4ef85dd81f to your computer and use it in GitHub Desktop.
Thread pool exceptions swallowing example
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class ThreadPoolExceptionExample {
public static void main(String[] args) throws Exception {
ExecutorService pool = Executors.newFixedThreadPool(1);
pool.submit(() -> {
throw new RuntimeException("You won't see this");
});
pool.shutdown();
pool.awaitTermination(1, TimeUnit.DAYS);
System.out.println("DONE");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment