What is main thread ?

When java program starts up, one thread begins running immediately. This is called main thread of the program.
It is the thread from which child threads are spawned.
It is the first thread to start and last to finish execution.
-it is created automatically when program is started.
-it’s priority is 5.
Example:
class demo
{
public static void main(String[] args){
System.out.println(Thread.currentThread());
}
};
Output:
Thread[main,5,main]

No comments:

Post a Comment