by Dinesh Thakur Category: Multithreading

 

 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
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content





Popular Article