A Developer Gateway To IT World...

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

(a) By extending Thread class

define thread by extending thread class

Define Thread by extending Thread class

class myThread  extends Thread
{
    public void run()
    {
        for(int i=1; i<=10; i++)
        {
            System.out.println("Child thread is running ");
        }
    }
}
class ThreadExtend
{
    public static void main(String args[]) throws InterruptedException
    {
        myThread t = new myThread();
        t.start();
        for(int i=1; i<=10;i++)
        {
            System.out.println("Main thread ");
        }
    }
}















LEARN TUTORIALS

.

.