bwLehrpool Masterserver
Manages authentication and sharing of virtual machines between participating institutions
PrioThreadFactory.java
Go to the documentation of this file.
1 package org.openslx.imagemaster.serverconnection;
2 
3 import java.util.concurrent.ThreadFactory;
4 import java.util.concurrent.atomic.AtomicInteger;
5 
6 public class PrioThreadFactory implements ThreadFactory {
7 
8  private final AtomicInteger counter = new AtomicInteger();
9  private final String name;
10  private final int priority;
11 
12  public PrioThreadFactory(String name, int priority) {
13  this.name = name;
14  this.priority = priority;
15  }
16 
17  @Override
18  public Thread newThread(Runnable r) {
19  Thread thread = new Thread(r, name + "-" + counter.incrementAndGet());
20  thread.setPriority(priority);
21  return thread;
22  }
23 
24 }