3:53 pm - Thursday March 24, 3436

Thread Example program for setName(int newPriority)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
//Example Program for setPriority() for thread in java
/**
@author:candidjava.com
@description:set the priority of the thread using SetPriority()method in java
*/
public class SetPriority implements Runnable {

Thread th;

public SetPriority() {
th = new Thread(this);
th.start();
}

public void run() {
//get the name of the thread
System.out.println( th.getName());
System.out.println("Current Thread priority is:"+th.getPriority());
//set Priority of the thread
th.setPriority(Thread.MIN_PRIORITY);

//get new Priority of the thread
System.out.println("New Priority of Thread is:"+th.getPriority());
}

public static void main(String[] args) {
new SetPriority();
}
}

OUTPUT:
Thread-0
Current Thread Priority is:5
New Thread priority is:1

Filed in: Z-A All Java Codes

Comments are closed.