Advertisement
d1i2p3a4k5

15. Inside main

Oct 18th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. class year extends Thread
  2. {
  3.     public void run()
  4.     {
  5.         try
  6.         {
  7.             String s1[] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
  8.             int i;
  9.             for(i=0;i<12;i++)
  10.             {
  11.                 System.out.println(s1[i]);
  12.                 Thread.sleep(2);
  13.             }
  14.         }
  15.         catch(InterruptedException ie)
  16.         {
  17.             System.out.println(ie);
  18.         }
  19.     }
  20. }
  21. class week extends Thread
  22. {
  23.     public void run()
  24.     {
  25.         try
  26.         {
  27.             String s2[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
  28.             int i;
  29.             for(i=0;i<7;i++)
  30.             {
  31.                 System.out.println(s2[i]);
  32.                 Thread.sleep(2);
  33.             }
  34.         }
  35.         catch(InterruptedException ie)
  36.         {
  37.             System.out.println(ie);
  38.         }
  39.     }
  40. }
  41. class my
  42. {
  43.     public static void main(String args[]) throws InterruptedException
  44.     {
  45.         year y = new year();
  46.         week w = new week();
  47.         y.start();
  48.         w.start();
  49.         y.join();
  50.         w.join();
  51.         for(int i=1;i<=10;i++)
  52.         {
  53.             System.out.println("Inside main");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement