shz.core.thread.TFConfig Maven / Gradle / Ivy
package shz.core.thread;
import shz.core.NullHelp;
public final class TFConfig {
enum TFType {
CUSTOM, DEFAULT
}
final TFType type;
final String threadName;
boolean daemon;
int priority = Thread.NORM_PRIORITY;
ClassLoader cl;
Thread.UncaughtExceptionHandler eh;
private TFConfig(TFType type, String threadName) {
NullHelp.requireNonBlank(threadName);
this.type = type;
this.threadName = threadName;
}
public static TFConfig custom(String threadName) {
return new TFConfig(TFType.CUSTOM, threadName);
}
public static TFConfig of(String threadName) {
return new TFConfig(TFType.DEFAULT, threadName);
}
public TFConfig daemon(boolean daemon) {
this.daemon = daemon;
return this;
}
public TFConfig priority(int priority) {
this.priority = priority;
return this;
}
public TFConfig cl(ClassLoader cl) {
this.cl = cl;
return this;
}
public TFConfig eh(Thread.UncaughtExceptionHandler eh) {
this.eh = eh;
return this;
}
}