Java ThreadPool Executor awaitTermination() MethodThe awaitTermination() method of ThreadPoolExecutor class blocks until tasks in the thread pool completes the execution or time for execution elapses. SyntaxParametertimeout - the maximum time to wait unit - the time unit of the timeout argument ReturnsTrue if this executor terminated and false if the timeout elapsed before termination ThrowInterruptedException - if interrupted while waiting Example 1Test it NowOutput: creating service await termination for thread:pool-1-thread-1 null Example 2Test it NowOutput: allowCoreThreadTimeOut is already true In Runnable!
Next TopicJava ThreadPoolExecutor
|