io.github.linmoure.thread.runnable.LabelRunnable Maven / Gradle / Ivy
package io.github.linmoure.thread.runnable;
public interface LabelRunnable extends Runnable {
String generateLabel();
void bnsRun();
@Override
default void run() {
String currentLabel = this.generateLabel();
String threadName = Thread.currentThread().getName();
if (currentLabel != null && !currentLabel.equals(threadName)) {
Thread.currentThread().setName(currentLabel);
}
this.bnsRun();
}
}