Thank you Oliver. I replaced my code with:
import java.util.concurrent.ThreadFactory;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
public final class DaemonThreadFactory {
public static ThreadFactory create(String namingPattern) {
// @formatter:off
return new BasicThreadFactory.Builder()
.namingPattern(namingPattern)
.daemon(true)
.priority(Thread.MAX_PRIORITY)
.build();
// @formatter:on
}
}
Gary
On Tue, Dec 19, 2017 at 1:34 PM, Oliver Heger <[email protected]>
wrote:
>
>
> Am 19.12.2017 um 17:27 schrieb Gary Gregory:
> > I keep on copying this from project to project and it seems fitting for
> > Commons Lang:
>
> In the concurrent package, there is the BasicThreadFactory class. Could
> this class satisfy your needs or can it be extended?
>
> Oliver
>
> >
> > import java.util.concurrent.ThreadFactory;
> > import java.util.concurrent.atomic.AtomicLong;
> >
> > public final class DaemonThreadFactory implements ThreadFactory {
> >
> > private final static AtomicLong COUNT = new AtomicLong(1);
> >
> > private final String name;
> >
> > public DaemonThreadFactory(final String name) {
> > super();
> > this.name = name;
> > }
> >
> > @Override
> > public Thread newThread(final Runnable r) {
> > final Thread thread = new Thread(r, name + " " +
> > COUNT.getAndIncrement());
> > thread.setDaemon(true);
> > return thread;
> > }
> >
> > }
> >
> > Thoughts?
> >
> > Gary
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>