3:03 am - Friday April 19, 2019

Thread Example program for setName(sring name)

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
//Program for setName() Method in thread
/**
@author:candidjava.com
@Description:Using setName() method for naming the Thread
*/
public class Setnam implements Runnable
{
public void run()
{
System.out.println(Thread.currentThread());
}
public static void main(String args[])
{
//create a new thread
Thread t1=new Thread();
//set the name for thread
t1.setName("Thread a");
t1.start();
//get the name of the thread
System.out.println("name of the thread:"t1.getName());
}
}


OUTPUT:
name of the thread:Thread a

Filed in: Z-A All Java Codes

Comments are closed.