Wednesday, 21 October 2015

Thread example in java (Java Threads)

import java.lang.Thread;
public class First {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Initial Thread demo example");
Thread t = Thread.currentThread();
System.out.println("The current thread is " +t);
System.out.println("Its name is " +t.getName());


}

}


output:-
Initial Thread demo example
The current thread is Thread[main,5,main]
Its name is main

No comments:

Post a Comment