Saturday, 14 May 2022

Advance java Slip21-Write a java program to display name and priority of a Thread

Write a java program to display name and priority of a Thread.

 

class Slip21

{

public static void main(String a[])

{

String S;

int p;

Thread t = Thread.currentThread();

S = t.getName();

System.out.println("\n Current Thread name : "+S);

p = t.getPriority();

System.out.println("\n Current thread priority : "+p);

t.setName("My Thread");

S = t.getName();

}

}