changeset 1229:32d02cd39320

7901430: WorkerThreadFactory instantiates default thread factory for each thread
author shade
date Fri, 22 May 2015 11:57:06 +0300
parents 16f9d77c2233
children 10560d7513f4
files jmh-core/src/main/java/org/openjdk/jmh/runner/WorkerThreadFactory.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkerThreadFactory.java	Fri May 15 13:25:25 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkerThreadFactory.java	Fri May 22 11:57:06 2015 +0300
@@ -30,16 +30,19 @@
 
 class WorkerThreadFactory implements ThreadFactory {
 
-    private final AtomicInteger counter = new AtomicInteger();
+    private final AtomicInteger counter;
     private final String prefix;
+    private final ThreadFactory factory;
 
     public WorkerThreadFactory(String prefix) {
+        this.counter = new AtomicInteger();
         this.prefix = prefix;
+        this.factory = Executors.defaultThreadFactory();
     }
 
     @Override
     public Thread newThread(Runnable r) {
-        Thread thread = Executors.defaultThreadFactory().newThread(r);
+        Thread thread = factory.newThread(r);
         thread.setName(prefix + "-jmh-worker-" + counter.incrementAndGet());
         thread.setDaemon(true);
         return thread;