Simple Thread Example

class ThreadDemo
{
public static void main(String main[])
{
    Thread t=Thread.currentThread();
    System.out.println("Current Thread : "+t);
    //change the name of the thread
    t.setName("My thread");
    System.out.println("Current Thread after name changed : "+t);
    System.out.println("Number of active threads : "+t.activeCount());


}
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|