Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import java.util.

Scanner;
public class Thread1 extends Thread{

@Override
public void run(){
System.out.println("");
System.out.println(Thread1.currentThread().getName()) ;
}

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

Thread1 t1 = new Thread1();


Thread1 t2 = new Thread1();
Thread1 t3 = new Thread1();

System.out.println("Name your first thread : ");


String Name1 = scan.next();
System.out.print("Enter prio level : ");
int priority1 = scan.nextInt();
System.out.println("");

System.out.println("Name your second thread : ");


String Name2 = scan.next();
System.out.print("Enter prio level : ");
int priority2 = scan.nextInt();
System.out.println("");

System.out.println("Name your third thread : ");


String Name3 = scan.next();
System.out.print("Enter prio level : ");
int priority3 = scan.nextInt();
System.out.println("");

t1.setName(Name1);
t2.setName(Name2);
t3.setName(Name3);

t1.setPriority(priority1);
t2.setPriority(priority2);
t3.setPriority(priority3);

System.out.println(t1.getName() +" - " + t1.getPriority());


System.out.println(t2.getName() +" - " + t2.getPriority());
System.out.println(t3.getName() +" - " + t3.getPriority());

System.out.println("");
System.out.println("Starting the threads...");
t1.start();
t2.start();
t3.start();

}
}

You might also like