One of the most common ways to create a separate parallel threads in an application to
, and perform useful tasks in them is the inheritance of
class and override the method
, which will be carried out and useful application code. When meeting with threads have read different opinions on this subject, and in this lesson will get acquainted with one of the possible ways to work with streams, but which are not considered to be the best option.
In general, if we make the class inherit from the
, it is logical to assume that this is done with the intention that it is not sufficient functionality of the class. But when this is done only with the aim to bring in, which must be performed in a separate thread
method a useful code, then there is clearly something wrong. In addition, de might be a problem with scaling applications and reuse code, particularly hard this can be shown in the case where such inherited class becomes quite a lot.
This method is the low level, and is used primarily for customization native streams. What is somewhat contrary to the usual need to complete a task in a separate thread. That is, as mentioned above, such an approach is primarily needed to extend the functionality class. Nevertheless, this method is necessary to consider what and proceed.