View Javadoc

    1   package net.sourceforge.pmd.processor;
    2   import java.util.Collections;
    3   import java.util.LinkedList;
    4   import java.util.List;
    5   import java.util.concurrent.ThreadFactory;
    6   import java.util.concurrent.atomic.AtomicInteger;
    7
    8   import net.sourceforge.pmd.RuleContext;
    9   import net.sourceforge.pmd.RuleSetFactory;
    10
    11  public class PmdThreadFactory implements ThreadFactory {
    12
    13  		private final RuleSetFactory ruleSetFactory;
    14  		private final RuleContext ctx;
    15  		private final AtomicInteger counter = new AtomicInteger();
    16
    17  		public PmdThreadFactory(RuleSetFactory ruleSetFactory, RuleContext ctx) {
    18  			this.ruleSetFactory = ruleSetFactory;
    19  			this.ctx = ctx;
    20  		}
    21
    22  		public Thread newThread(Runnable r) {
    23  			Thread t = PmdRunnable.createThread(counter.incrementAndGet(), r,
    24  					ruleSetFactory, ctx);
    25  			threadList.add(t);
    26  			return t;
    27  		}
    28
    29  		public List<Runnable> threadList = Collections
    30  				.synchronizedList(new LinkedList<Runnable>());
    31
    32  }