// by extending thread class
public class thr1 extends Thread
{
public void run()
{
System.out.println("thread runing");
}
public static void main (String arg[])
{
thr1 x= new thr1();
x.start();
}
}
// by implementig runnable interface
public class thr2 implements Runnable
{
public void run()
{
System.out.println("thread runing");
}
public static void main (String arg[])
{
thr2 x= new thr2();
Thread t=new Thread(x);
t.start();
}
}
No comments:
Post a Comment