Java

Java

Made by DeepSource

Thread with empty run method is useless JAVA-W0084

Anti-pattern
Major

A thread was created using the default empty run method.

This method creates a thread with the default empty run method. When this thread is launched, it will exit as soon as it is scheduled since there is no code to run.

Bad Practice

Thread t = new Thread();

// The launched thread does nothing.
t.start();

Recommended

Thread t = new Thread(
    new Runnable {
        @Override
        void run() {
            // ...
        }
    }
);

Make sure to provide a valid Runnable instance to the Thread constructor while initializing it.

References