Java Executors newScheduledThreadPool() MethodThe newScheduledThreadPool() method of Executors class creates a thread pool that can schedule commands to run after a given delay or to execute periodically. SyntaxParametercorePoolSize - the number of threads to keep in the pool, even if they are idle threadFactory - the factory to use when the executor creates a new thread Returnsa newly created scheduled thread pool ThrowNullPointerException IllegalArgumentException Example 1Test it NowOutput: class java.util.concurrent.ScheduledThreadPoolExecutor size of mypool: 0 Thread Name: pool-2-thread-1 after sleep Thread Name: pool-2-thread-1 Example 2Test it NowOutput: class java.util.concurrent.ScheduledThreadPoolExecutor size of mypool: 0 false class java.util.concurrent.ScheduledThreadPoolExecutor 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