Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread

 
rahul R khanna
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
main() method of a class can be invoked in another class.
Whenever Main method is called, a Main thread gets started right?
In this case how many threads get started?
class a
{
static void main(String args[])
{
System.out.println("----a-----");
}
}
public class b
{
public static void main(String args[])
{
System.out.println("----b-----");
a.main(new String[10]);
}
}


someone expalain this please.

regards
rahul
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rahul R khanna:
Whenever Main method is called, a Main thread gets started right?


No. There is nothing special about the main method. It's just like any other method. When it is used as the entry point to a java program, the JVM creates a thread and then calls the main method using that thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic