5
To create a Thread we can both extend the class Thread and overwrite the method run()
, how to have a class that implements the interface Runnable, implement the method run()
and pass the reference of an object of this class that we created as an argument to the constructor of Thread.
Observing the code of the method start()
I saw you make a call to the method run()
which could, in my view, be interpreted as a step towards implementing the start()
of Thread.
It would be possible to apply the method template using composition?
The class Thread package java.lang
could be seen as a good example of this pattern using composition?
Given the definition of Pattern:
Define the skeleton of an algorithm in an operation, letting subclasses complete some of the steps.
It would be possible to state what was exposed above?