class MyClass implements Runnable
{
int n = 0;
public MyClass(int n){ this.n = n; }
public static void main(String[] args)
{
new MyClass(2).run();
new MyClass(1).run();
}
public void run()
{
for(int i=0; i<n; i++)
{
System.out.println("Hello World");
}
}
}
What will be the output when this program is compiled and run from the command line?
Should'nt the answer be
1 new thread is created by the program.
as the main method itself is a thread?
Concurrency topic wise question 8
Moderator: admin
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Concurrency topic wise question 8
Hello,
The main thread is created by JVM and not by the program code.
HTH,
Paul.
The main thread is created by JVM and not by the program code.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 18 guests