Java ThreadPoolExecutor remove() MethodThe remove() method of ThreadPoolExecutor class removes this task from the executor's internal queue if it is present, thus causing it not to be run if it has not already started. SyntaxParametersTask - the task to remove ReturnThe true if the task was removed ThrowDoes not throw the exception. Example 1Test it NowOutput: Running Thread Name: pool-1-thread-2 Running Thread Name: pool-1-thread-1 Completed Thread Name: pool-1-thread-1 Completed Thread Name: pool-1-thread-2 Example 2Test it NowOutput: Starting threads i=5 i=5
Next TopicJava ThreadPoolExecutor
|