org.polkadot.common.NamedThreadFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polkadot-java Show documentation
Show all versions of polkadot-java Show documentation
Java Polkadot API, this is a clone of https://github.com/polkadot-java/api
The newest version!
package org.polkadot.common;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class NamedThreadFactory implements ThreadFactory {
private ThreadGroup group;
private AtomicInteger threadCountor = new AtomicInteger(0);
private String name;
public NamedThreadFactory(String perfix) {
this.name = perfix;
group = new ThreadGroup(name);
}
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(group, runnable, name + "-" + threadCountor.incrementAndGet());
return thread;
}
public String getName() {
return name;
}
public ThreadGroup getGroup() {
return group;
}
}