A subclass of Thread neither overrides run() nor passes a task to its constructor
What it finds
A class that extends Thread but does not override run(), and passes no task to the Thread constructor, starts threads that do nothing: Thread.run() runs only a task given to the constructor.
From the rule's source, thread_without_task.rs.
class Idle extends Thread {tx0 reports: Idle extends Thread but gives it nothing to run Idle() { setDaemon(true); }} class Busy extends Thread { @Override public void run() {}} class Wrapped extends Thread { Wrapped(Runnable task) { super(task); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:thread-without-task" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:thread-without-task] reason="..."tx0 explain tx0/java:thread-without-task shows the same in the terminal. Found a false positive? Report it.