A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Program for join method

class MyThread extends Thread
{
    public void run()
    {
        for(int i=0; i<10; i++)
        {
            System.out.println("my thread");
            try
            {
                Thread.sleep(2000);
            }
            catch(InterruptedException e)
            {
               
            }
        }
    }
}
class join
{
    public static void main(String args[]) throws InterruptedException
    {
        MyThread t=new MyThread();
        t.start();
        t.join();
        for(int i=0; i<10;i++)
        {
            System.out.println("This is your Thread");
        }
    }

}

output:


LEARN TUTORIALS

.

.