blob: 5fa9da450c7a5c7e2db50c21c01062157b53e3f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package org.openslx.imagemaster.serverconnection;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class PrioThreadFactory implements ThreadFactory {
private final AtomicInteger counter = new AtomicInteger();
private final String name;
private final int priority;
public PrioThreadFactory(String name, int priority) {
this.name = name;
this.priority = priority;
}
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, name + "-" + counter.incrementAndGet());
thread.setPriority(priority);
return thread;
}
}
|