Java ThreadPoolExecutor isTerminated() MethodThe isTerminated() method of ThreadPoolExecutor class returns true if all the tasks have been completed following shut down. Here, we must notice that isTerminated() never returns true unless either shut down or shutdownNow was called first. SyntaxParametersNo parameter is passed. ReturnTrue if all the tasks have been completed following shut down ThrowDoes not throw the exception. Example 1Test it NowOutput: get Task count after:2 Is Executor is Terminated :false Running Thread Name: pool-1-thread-2 Running Thread Name: pool-1-thread-1 Completed Thread Name: pool-1-thread-2 Completed Thread Name: pool-1-thread-1 Example 2Test it NowOutput: Starting threads Maximum pool size: 2147483647 get Task count before:0 get Task count after:2 Is Executor is Terminated :false Threads started, main ends i=5 i=5
Next TopicJava ThreadPoolExecutor
|