I’d like to log the number of active threads created by a newCachedThreadPool call. I can’t seem to find out where to get this value though.
I’d like to log the number of active threads created by a newCachedThreadPool call.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can pass a
ThreadFactorytonewCachedThreadPoolLet it implement some logging when creating a new Thread, since newCachedThreadPool reuses threads you don’t have to worry about threads end.
OR
Cast the executor into a
ThreadPoolExecutorand call itsgetPoolSize()method