JAVA Program using Threads to Print Even Numbers up to 100 and Alphabets alternately

JAVA Program using Threads to Print Even Numbers up to 100 and Alphabets alternately:

import java.io.*;
class alpha extends Thread
{
 public void run()
 {
   char i;
   for(i='A';i<='Z';i++)
   {
     System.out.print("\t"+i);
     i++;
   }
   System.out.println();
 }
}

class even extends Thread
{
 public void run()
 {

   for(int i=1;i<=100;i++)
   {
       if(i%2==0)
       {
    System.out.println(i);
       }
   }
  }
}
class thread3
{
    public static void main(String args[])
    {
        alpha a=new alpha();
        a.start();
        a.setPriority(Thread.MAX_PRIORITY);
        even e=new even();
        e.setPriority(Thread.MIN_PRIORITY);
        e.start();

    }
}

OUTPUT:

A       C       E       G       I       K       M       O       Q       S       U       W       Y

2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.