Finals OOP Hands On Act
Finals OOP Hands On Act
Finals OOP Hands On Act
Scanner;
public class ThreadDemo implements Runnable{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
ThreadDemo td = new ThreadDemo();
T1.setName(name1);
T2.setName(name2);
T3.setName(name3);
T4.setName(name4);
T1.start();
T2.start();
T3.start();
T4.start();
try{
T1.sleep(500);
T2.sleep(1000);
T3.sleep(1500);
T4.sleep(2000);
}catch(Exception e){
e.printStackTrace();
}
System.out.println("\n===After Sleep===");
System.out.println(T1.getName() + " is " + T1.getState() + "\n" +
T2.getName() + " is " + T2.getState() +"\n" + T3.getName() + " is " + T3.getState()
+"\n" + T4.getName() + " is " + T4.getState() );
}
@Override
public void run(){
}
}