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();
}
}