Tuesday, 4 March 2025

Write a java program to create the following threads. a) To print from 100 to 1. b) To print alphabet a to z c)To print vowels.


import java.lang.*; 

//  to print numbers from 100 to 1

class NumberThread extends Thread

{

    public void run()

    {

        for(int i = 100; i >= 1; i--)

        {

            System.out.println("Number : " + i);

        }

    }

}


//  to print alphabets from a to z

class AlphabetThread extends Thread

{

    public void run()

    {

        for(char ch = 'a'; ch <= 'z'; ch++)

        {

            System.out.println("Alphabet : " + ch);

        }

    }

}





// Thread to print vowels

class VowelThread extends Thread

{

    public void run()

    {

        char vowels[] = {'a','e','i','o','u'};

        for(int i = 0; i < vowels.length; i++)

        {

            System.out.println("Vowel : " + vowels[i]);

        }

    }

}

class ThreadExample

{

    public static void main(String args[])

    {

        NumberThread t1 = new NumberThread();

        AlphabetThread t2 = new AlphabetThread();

        VowelThread t3 = new VowelThread();

        t1.start();

        t2.start();

        t3.start();

    }

}