72.multi - threading by implementing runable interfce in java
//multi - threading by implementing runable interfce
class MyThread2 implements Runnable
{
public void run()
{
try
{
for (int i = 10; i >= 1; i-- ) {
System.out.println("\t" + i);
Thread.sleep(100);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
class threading2
{
public static void main(String[] args) {
MyThread2 obj = new MyThread2();
Thread t = new Thread(obj);
t.start();
System.out.println("End...");
}
}
OUTPUT:
End...
10
9
8
7
6
5
4
3
2
1
Comments
Post a Comment