Java

Java

Made by DeepSource

Thread.currentThread() should not be used to call Thread's static methods JAVA-W1038

Anti-pattern
Major
Autofix

This method invokes Thread.currentThread() just to call one of Thread's static methods.

Most static methods of Thread operate on the current thread, so there is no need to explicitly get the current thread object to call them.

Bad Practice

boolean isInterrupted = Thread.currentThread().interrupted();

Recommended

Just use the method with Thread's class instance directly.

isInterrupted = Thread.interrupted();

References