It is possible to create various type of Thread Executors in Java, singleThreadedExecutor, fixedThreadedExecutor etc. Is there any way I can add something so that when I invoke getThreadName() and getThreadID() on an executing thread, I can see what Thread executor it has come from?
Thanks.
Yes. You supply these factory methods with a
ThreadFactoryimplementation. This is a thing that makes aThreadfrom aRunnable. So you can do whatever you like in the method, such as set its name, priority or daemon status — even employ a customThreadsubclass.