Created
January 28, 2021 11:58
-
-
Save bademux/bfaf2f414a49810bb7fc41205fe652ee to your computer and use it in GitHub Desktop.
Run task in current thread. Handy for testing. How it works: when thread factory returns null, ThreadPoolExecutor invokes CallerRunsPolicy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UtilityClass | |
public class ExecutorUtils { | |
public static ExecutorService currentThreadExecutorService() { | |
return new ThreadPoolExecutor(0, 1, 0L, SECONDS, new SynchronousQueue<>(), r -> null, new CallerRunsPolicy()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment