tuesday Thread revision
package com.company;
class myThread extends Thread {
int i = 0;
public void run() {
while (i < 1000) {
System.out.println("Hello i am inside run method in myThread class");
i++;
}
}
public void meth() {
while (i < 1000) {
System.out.println("Prantika bahut acchi hai!");
i++;
}
}
}
class hello implements Runnable {
int a = 0;
public void run() {
while (a < 1000) {
System.out.println("I am implementing runnable interface");
a++;
try {
Thread.sleep(78888);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public class CWR_Tuesday {
public static void main(String[] args) {
myThread obj= new myThread();
hello obj1= new hello();
Thread first = new Thread(obj1);
// System.out.println(first.getId());
// System.out.println(obj.getId());
// System.out.println(obj.getName());
// System.out.println(first.getName());
obj.start();
System.out.println(obj.getState());
// try {
// obj.join();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// first.setPriority(8);
first.start();
System.out.println(first.getState());
System.out.println(obj.currentThread().getId());
}
}
Comments
Post a Comment