org.sonar.l10n.java.rules.squid.S2134.html Maven / Gradle / Ivy
According to the Java API documentation:
There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started...
The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started.
By definition, extending the Thread class without overriding the run
method doesn't make sense, and implies that the contract of the Thread
class is not well understood.
Noncompliant Code Example
public class MyRunner extends Thread { // Noncompliant; run method not overridden
public void doSometing() {...}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy