Tuesday, 3 May 2022

A) Write a java program to display name of currently executing Thread in multithreading.

 

Slip 13Q1

Save as     "Slip13Q21"


CODE:

class Slip13Q1 extends Thread{
    @Override
    public void run() {
        System.out.println("Current thread is "+getName());
    }
    public static void main(String[] args) {
        Slip13Q1 thread1 = new Slip13Q1();
        thread1.setName("first thread");
        Slip13Q1 thread2 = new Slip13Q1();
        thread2.setName("second thread");
        Slip13Q1 thread3 = new Slip13Q1();
        thread3.setName("third thread");
        Slip13Q1 thread4 = new Slip13Q1();
        thread4.setName("fourth thread");
        Slip13Q1 thread5 = new Slip13Q1();
        thread5.setName("fifth thread");

        thread1.run();
        thread2.run();
        thread3.run();
        thread4.run();
        thread5.run();
    }
}

No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...