Chapter13 Thread practice

 package com.company;

class gm extends Thread{
public void run(){
while(true){
System.out.println("Good morning");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class we extends Thread{
public void run(){
while(true) {
System.out.println("Welcome");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public class CWH_76_ch13_ps {
public static void main(String[] args) {
// Problem 1
gm g=new gm();
g.setPriority(6);
we w= new we();
w.setPriority(8);
System.out.println(g.getPriority());
System.out.println(w.getPriority());
System.out.println(w.getState());
g.start();
w.start();
System.out.println(w.getState());
System.out.println(Thread.currentThread().getState()); //reference

}
}

Comments