Java ThreadPoolExecutor toString() MethodThe toString() method of ThreadPoolExecutor class returns the string representation of the ThreadPoolExecutor object. SyntaxParametersNA ReturnA string identifying this pool, as well as its state ThrowDoes not throw the exception. Example 1Test it NowOutput: toString :java.util.concurrent.ThreadPoolExecutor@33909752[Shutting down, pool size = 2, active threads = 2, queued tasks = 0, completed tasks = 0] 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 toString :java.util.concurrent.ThreadPoolExecutor@55f96302[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
Next TopicJava ThreadPoolExecutor
|