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
|