public class Threadgroup {
public static void main(String[] args) {
ThreadGroup grp = new ThreadGroup("group1");
mythread m1 = new mythread(grp, "thread1");
mythread m2 = new mythread(grp, "thread2");
mythread m3 = new mythread(grp, "thread3");
m1.start();
m2.start();
m3.start();
}
}
class mythread extends Thread {
public mythread(ThreadGroup g, String s) {
super(g, s);
}
@Override
public void run() {
System.out.println("Thread group, prority, thread name "
+ Thread.currentThread());
}
}
Output :
Thread group, prority, thread name Thread[thread2,5,group1] Thread group, prority, thread name Thread[thread3,5,group1] Thread group, prority, thread name Thread[thread1,5,group1]