Пример #1
0
 public static int getCurrentNestedThreadLevel(final String threadNameContains) {
   int nestedLevel = 0;
   final String threadname = Thread.currentThread().getName();
   final String[] nestedThreads =
       Strings.splitByWholeSeparator(threadname, Threads.NESTED_THREAD_NAME_SEPARATOR);
   for (final String nestedThread : nestedThreads) {
     if (nestedThread.contains(threadNameContains)) {
       nestedLevel++;
     }
   }
   return nestedLevel;
 }
Пример #2
0
 public static void updateParentThreadName(final String parentThreadName) {
   final String curThreadName =
       Strings.substringBefore(Thread.currentThread().getName(), NESTED_THREAD_NAME_SEPARATOR);
   Thread.currentThread().setName(curThreadName + NESTED_THREAD_NAME_SEPARATOR + parentThreadName);
 }