by Dinesh Thakur

 

 class UserDefineThread extends Thread

   {
       UserDefineThread(String Nme)
        {
             super("Example of join Thread in Java");
            start();
        }
           public void run()
           {
              try
                 {
                    for(int loop_indx =0;loop_indx<4;loop_indx++)
                    {
                       System.out.println((Thread.currentThread()).getName()+ "Here's The Thread...");
                           Thread.sleep(500);
                       }
                 } 
                   catch (InterruptedException e1) {}
                       System.out.println((Thread.currentThread()).getName() + "Finishing");
          }
  }
                 class JavaExampleJoinThread
                 {
                     public static void main(String aa[])
                      {
                          UserDefineThread ThreadOne = new UserDefineThread("First");
                          UserDefineThread ThreadTwo = new UserDefineThread("Second");
                          UserDefineThread ThreadThree = new UserDefineThread("Third");
                          UserDefineThread ThreadFour = new UserDefineThread("Fourth");
                          try
                        {
                               ThreadOne.join();
                               ThreadTwo.join();
                               ThreadThree.join();
                               ThreadThree.join();
                           }              
                          catch (InterruptedException e2) {}
                    }
              }
Java Example for JoinThread