How to Create a Thread using Thread class in Core Java

In this tutorial how to create a Thread using Thread class in Core Java is shown.

Code:

Thread1.java

class MyThread extends Thread
{
public void run()
{
try
{
for(int i=0;i<10;i++)
{
Thread.sleep(2000);
System.out.print(” “+String.valueOf(i));
}
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
}
}

class ThreadDemo
{
public static void main(String args[])
{
MyThread t1=new MyThread();
t1.start();
}
}

https://youtu.be/RvO7SVBTjHY

Add a Comment

Your email address will not be published. Required fields are marked *