Thread by extending thread
class MyThread extends Thread {
int n;
MyThread(int n) {
this.n = n;
}
public void run() {
for (int i = 1; i <= n; i++) {
System.out.println(i);
}
}
public static void main(String[] args) {
MyThread t = new MyThread(5);
t.start();
}
}
Comments
Post a Comment