1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-14 05:15:03 -05:00
filebot/source/net/sourceforge/tuned/DefaultThreadFactory.java
Reinhard Pointner 87e8d830ce * full support for multiple checksum types (SFV, MD5, SHA-1)
notes:
* updated to MigLayout 3.6.3
* better exception handling in *TransferablePolicy
* added checksum toggle button and artwork
* poperly cancel computation tasks on reset
* better "Total Progress" visibility behaviour
* improved checksum table model classes, better update/repaint behaviour
2009-02-15 12:20:43 +00:00

49 lines
1.0 KiB
Java

package net.sourceforge.tuned;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class DefaultThreadFactory implements ThreadFactory {
private final AtomicInteger threadNumber = new AtomicInteger(0);
private final ThreadGroup group;
private final int priority;
private final boolean daemon;
public DefaultThreadFactory(String name) {
this(name, Thread.NORM_PRIORITY);
}
public DefaultThreadFactory(String name, int priority) {
this(name, priority, false);
}
public DefaultThreadFactory(String groupName, int priority, boolean daemon) {
group = new ThreadGroup(groupName);
this.daemon = daemon;
this.priority = priority;
}
public Thread newThread(Runnable r) {
Thread thread = new Thread(group, r, String.format("%s-thread-%d", group.getName(), threadNumber.incrementAndGet()));
if (daemon != thread.isDaemon())
thread.setDaemon(daemon);
if (priority != thread.getPriority())
thread.setPriority(priority);
return thread;
}
}