Ishmam_Rahman

JAVA_Multitask

May 6th, 2021
332
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Simple1 extends Thread{
  2.  public void run(){
  3.    System.out.println("Tom Start");
  4.   try{Thread.sleep(50);}catch(InterruptedException e)
  5.    {System.out.println(e);}
  6.  try{Thread.sleep(50);}catch(InterruptedException e)
  7.    {System.out.println(e);}
  8.    System.out.println("Tom Reach");
  9.  }
  10. }
  11.  
  12. class Simple2 extends Thread{
  13.  public void run(){
  14.    System.out.println("Jerry Start");
  15.    try{Thread.sleep(50);}catch(InterruptedException e)
  16.    {System.out.println(e);}  
  17.   System.out.println("Jerry Reach");
  18.  }
  19. }
  20.  
  21. class Simple3 extends Thread{
  22.  public void run(){
  23.    System.out.println("Jhon start");
  24.    try{Thread.sleep(500);}catch(InterruptedException e)
  25.    {System.out.println(e);}  
  26.   System.out.println("Jhon reach");
  27.  }
  28. }
  29.  
  30.  class TestMultitasking3{
  31.  public static void main(String args[]){
  32.   Simple1 t1=new Simple1();
  33.   Simple2 t2=new Simple2();
  34.   Simple3 t3=new Simple3();
  35.  
  36.   t1.start();
  37.   t2.start();
  38.   t3.start();
  39.  }
  40. }
  41.  
RAW Paste Data