class EvenNo implements Runnable
 {
Thread t;
int no,test;
boolean running = true;
EvenNo(int n)
{
t=new Thread(this);
t.start();
no = n;
test = 1;
}

public void run()
{
 try{
        while(running)
        {
          if(test % 2 == 0)
  System.out.println("\t The Even thread is executing,Even no = " + test);
 if(test == no)
   running = false;
 test++;
 t.sleep(200);
}
      }catch(InterruptedException e){e.printStackTrace();}
     
    }

}
class Vowels implements Runnable
{
Thread t1;
char ch = 65;
boolean running = true;
Vowels()
{
t1=new Thread(this);
t1.start();      
}

public void run()
{
         try
    {
      while(running)
      {
       if(ch =='a' || ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
         System.out.println("Vowel Thread, Vowel is :: " + ch);
       if(ch == 122)
         running = false;
       ch++;      
   t1.sleep(200);  
  }
}catch(InterruptedException e){e.printStackTrace();  }
}
  }

class evnvowel
 {
public static void main(String ar[])
  {
EvenNo t1=new EvenNo(50);
Vowels t2=new Vowels();
   }
  }

Post a Comment

Previous Post Next Post