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:
ThreadPoolExecutor
class 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)
, inThreadPoolExecutor
are concrete with empty method body, whereas hook methods inabstract
class of template method pattern areabstract
albeit the fact that both hook methods areprotected
indicating that they should beoverridden
in their subclasses
So my QUESTIONS are:
- does the
ThreadPoolExecutor
belong to template method pattern at all? - Is the hook method per se. an independent technique from the template method pattern?