blob: d4987cc06334c40f1e7b30088ab44dbaa82e9f9d (
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
25
26
27
28
29
30
31
32
|
package org.openslx.util;
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;
}
public PrioThreadFactory( String name )
{
this( name, Thread.NORM_PRIORITY );
}
@Override
public Thread newThread( Runnable r )
{
Thread thread = new Thread( r, name + "-" + counter.incrementAndGet() );
thread.setPriority( priority );
return thread;
}
}
|