Regarding joining of threads
<p>I have developed the below program on java threads , I have two threads which are executing and accessing the method inside run() now if I want to first thread to begin first and then second thread that I have done through synchronization mechanism but if I want first thread to end first and then began with second thread that could be achievable through join() , please advise me how this can be done by implementing join, </p>

<pre><code>public class MyThread2 extends Thread  {


public  void  run()
{

    //synchronized (this)
    //{
    //System.out.println(Thread.class);
    for(int i=0;i&lt;20;i++)
    {
        try{

            Thread.sleep(500);
            System.out.println(Thread.currentThread().getName());
        System.out.println(i +"\n"+ "..");
        }catch(Exception e)
        {e.printStackTrace();
        }
    }
    //}
</code></pre>

<p>}</p>

<pre><code>public static void main(String... a )
{
    MyThread2 obj = new MyThread2();

    Thread x = new Thread(obj);
    x.setName("first");
    x.start();

    Thread y = new Thread(obj);
    y.setName("second");
    y.start();




}
</code></pre>
