Java Executors newSingleThreadExecutor() MethodThe newSingleThreadExecutor() method of Executors class creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution before the shutdown, a new one will take its place if needed to execute subsequent tasks.). SyntaxParameterthreadFactory - the factory to use when creating new threads Returnsthe newly created single-threaded Executor ThrowsNullPointerException Example 1Test it NowOutput: current thread : main Executor Service... Runnable... Submit the task :: pool-1-thread-1 Example 1Test it NowOutput: Shutingdown executor Running Task! Next TopicJava Executors |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India