Added thread-group name as a prefix to the thread-group pattern.
Change-Id: Id804ba00f2391d18a1bc4ea06cd39934208d6c18
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index e366172..8b045f1 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -43,6 +43,9 @@
import static org.onlab.util.GroupedThreadFactory.groupedThreadFactory;
import static org.slf4j.LoggerFactory.getLogger;
+/**
+ * Miscellaneous utility methods.
+ */
public abstract class Tools {
private Tools() {
@@ -68,7 +71,9 @@
* Returns a thread factory that produces threads named according to the
* supplied name pattern and from the specified thread-group. The thread
* group name is expected to be specified in slash-delimited format, e.g.
- * {@code onos/intent}.
+ * {@code onos/intent}. The thread names will be produced by converting
+ * the thread group name into dash-delimited format and pre-pended to the
+ * specified pattern.
*
* @param groupName group name in slash-delimited format to indicate hierarchy
* @param pattern name pattern
@@ -77,7 +82,7 @@
public static ThreadFactory groupedThreads(String groupName, String pattern) {
return new ThreadFactoryBuilder()
.setThreadFactory(groupedThreadFactory(groupName))
- .setNameFormat(pattern)
+ .setNameFormat(groupName.replace(GroupedThreadFactory.DELIMITER, "-") + "-" + pattern)
// FIXME remove UncaughtExceptionHandler before release
.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception on {}", t.getName(), e)).build();
}