THREAD GROUP

Thread group


  • Thread Group:

    ThreadGroup is a class inside java.lang package. By using ThreadGroup we can change Group of threads states from one state to another state. Except start() method.

Example

  • Thread1 t=new Thread1();

  • Thread2 t2=new Thread2();

  • Thread3 t3=new Thread3();

  • ThreadGroup tg=new ThreadGroup();

  • Thread td1=new Thread(t,tg);

  • Thread td2=new Thread(t2, tg);

  • Thread td3=new Thread(t3, tg);

  • Td1.start();

  • Td2.start();

  • Tg.sleep();