Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static void showThreadName() { String groupName = Thread.currentThread().getThreadGroup().getName(); String threadName = Thread.currentThread().getName(); System.out.println(String.format("%s-%s", groupName, threadName)); } public static void showThreadName(int num) { String groupName = Thread.currentThread().getThreadGroup().getName(); String threadName = Thread.currentThread().getName(); System.out.println(String.format("%d: %s-%s", num, groupName, threadName)); } }