I am writing Junit test case for a method which does a job in background thread. To test the flow, I am planning to write a ExecutorService that I can use in my testcase. The ExecutorService should run the job in main thread. What I mean is that ExecutorService implementation should use the main thread to execute any task submitted to it. It must not create any worker thread. Anyone has sample code for that?