JAVA PROGRAM TO PERFORM MULTI THREADING USING RUNNABLE INTERFACE

 class Multithreading implements Runnable {

    public void run()

    {

        try {

            // Displaying the thread that is running

            System.out.println(

                "Thread " + Thread.currentThread().getId()

                + " is running");

        }

        catch (Exception e) {

            

            // Throwing an exception

            System.out.println("Exception is caught");

        }

    }

}


// Main Class

public class Geeks {

    public static void main(String[] args)

    {

        int n = 8; // Number of threads

        for (int i = 0; i < n; i++) {

            Thread object

                = new Thread(new Multithreading());

            object.start();

        }

    }

}

Comments

Popular posts from this blog

JAVA RECORD PROGRAM FOR FIBBONACCI SERIES

JAVA RECORD PROGRAM FOR AREA AND PERIMETER OF RECTANGLE

JAVA RECORD PROGRAM FOR MATRIX MULTIPLICATION