Creating threads
Threads are objects in the Java language. A thread can be defined by extending the java.lang.Thread class or by implementing the
java.lang.Runnable interface. The
run() method should be overridden and should have the code that will be executed by the new thread. This method must be public with a void return type and should not take any arguments.
Extending thread
If we need to inherit the behavior of the
Thread class, we can have a subclass of it. In this case, the disadvantage is that you cannot extend