There are 2 hook methods in the ThreadPoolExecutor.
This technique makes me think of the template method pattern, where there are hook methods in the abstract class. However, the hook methods in the abstract class of template method do differ from that of ThreadPoolExecutor in that:
ThreadPoolExecutorclass is concrete, whereas the class defining the hook methods in the template method pattern isabstract- hook methods, such as
beforeExecute(Thread t, Runnable r)andafterExecute(Runnable r, Throwable t), inThreadPoolExecutorare concrete with empty method body, whereas hook methods inabstractclass of template method pattern areabstractalbeit the fact that both hook methods areprotectedindicating that they should beoverriddenin their subclasses
So my QUESTIONS are:
- does the
ThreadPoolExecutorbelong to template method pattern at all? - Is the hook method per se. an independent technique from the template method pattern?