JAVA

PART -A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

5.

 
  
 /*
  PART-B
5.  Write a java program to demonstrate multithreading using runnable interface.
  
  */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;




public class program12b5 {

    public static void main(String[] args) {
        Thread object = new Thread(new MultiThread());
        object.start();
        for (int i = 0; i < 10; i++) {
            System.out.println("Main Thread id: " + Thread.currentThread().getId());
        }
    }
}
 
class MultiThread implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
        System.out.println("Thread " + Thread.currentThread().getId()+ " is running");
        }
    }
}