How to wait current thread execution and execute another thread completedly
<pre><code>public class Thread1 extends Thread {
    public void run() {
         testFun1();
    }

     public void testFun1(){
          for(int i=1;i&lt;10;i++){
              try {  
                  Thread.sleep(1000);
                      System.out.println("From testFun1() = "+i);
               } catch (Exception e) {
           }  

        }

      } 

    }

class Thread2 extends Thread {
    public void run(){
        testFun2();
    }

    public synchronized void testFun2() {
        try {
              for(int i=20;i&lt;=25;i++){
               Thread.sleep(1000);  
               System.out.println("From testFun2() = "+i);           
        }
      }
    }
</code></pre>

<hr>

<p>MainClass.java</p>

<pre><code>public class MainClass{
    public static void main(String[] args) {
       try{ 
        Thread1 thread1 = new Thread1();
        Thread2 thread1 = new Thread2();
        thread1.start();
        Thread.sleep(3000);
        thread1.join();
        thread2.start();
     }catch(Exception e){
     }

   }
}
</code></pre>

<hr>

<p>Required output:</p>

<pre><code>From testFun1() 1
From testFun1() 2
From testFun1() 3
From testFun2() 20
From testFun2() 21
From testFun2() 22
From testFun2() 23
From testFun2() 24
From testFun2() 25
From testFun1() 4
From testFun1() 5
From testFun1() 6
From testFun1() 7
From testFun1() 8
From testFun1() 9
From testFun1() 10
</code></pre>

<p>But didn't get the above out put.</p>
