-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...enchmark/src/main/java/com/tsurugidb/benchmark/costaccounting/util/NameThreadFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.tsurugidb.benchmark.costaccounting.util; | ||
|
||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class NameThreadFactory implements ThreadFactory { | ||
|
||
private final String baseName; | ||
|
||
private final AtomicInteger number = new AtomicInteger(0); | ||
|
||
public NameThreadFactory(String baseName) { | ||
this.baseName = baseName; | ||
} | ||
|
||
@Override | ||
public Thread newThread(Runnable r) { | ||
var thread = new Thread(r); | ||
thread.setName(baseName + number.getAndIncrement()); | ||
return thread; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nting-benchmark/src/main/java/com/tsurugidb/benchmark/costaccounting/util/ThreadUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.tsurugidb.benchmark.costaccounting.util; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
public class ThreadUtil { | ||
|
||
public static ExecutorService newFixedThreadPool(String baseName, int threads) { | ||
var factory = new NameThreadFactory(baseName); | ||
return Executors.newFixedThreadPool(threads, factory); | ||
} | ||
} |