71. multi - threading in java
//multi - threading by extending Thread class
class MyThread extends Thread
{
public void run()
{
try
{
for (int i = 1; i <= 10; i++ ) {
System.out.println("\t" + i);
Thread.sleep(100);
}
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
class threading1
{
public static void main(String[] args) {
MyThread obj = new MyThread();
obj.start();
System.out.println("End of Program");
}
}
OUTPUT:
End of Program
1
2
3
4
5
6
7
8
9
10
Comments
Post a Comment