Page 1 of 1

About Question enthuware.ocpjp.v8.2.1398 :

Posted: Sat Jan 11, 2020 5:38 pm
by Joost86
Is the main method not creating a thread? In that case, '1 new thread is created' would be true, right?

Re: About Question enthuware.ocpjp.v8.2.1398 :

Posted: Sun Jan 12, 2020 2:31 am
by admin
No, main method is not creating a thread. Which line of code in main method do you think is creating a thread?

Re: About Question enthuware.ocpjp.v8.2.1398 :

Posted: Sun Jan 12, 2020 6:05 am
by Joost86
Is starting the main method, not starting a thread?

'1 new thread is created by the code in this program.' seems somewhat ambiguous (what does 'creating' mean?)...

https://www.geeksforgeeks.org/main-thread-java/

Re: About Question enthuware.ocpjp.v8.2.1398 :

Posted: Sun Jan 12, 2020 8:09 am
by admin
"By the code in this program" is not ambiguous at all. The main thread that you are referring to is created by the JVM, and not by the code given in the program. To create a thread, you would have to use the Thread class either directly or indirectly.

Re: About Question enthuware.ocpjp.v8.2.1398 :

Posted: Sun Jan 10, 2021 7:50 am
by fukThe
Joost86 wrote:
Sun Jan 12, 2020 6:05 am
Is starting the main method, not starting a thread?

'1 new thread is created by the code in this program.' seems somewhat ambiguous (what does 'creating' mean?)...

https://www.geeksforgeeks.org/main-thread-java/
The Main Thread gets startet by the JVM as soon as you start your programm, than the main thread looks for the main method. The main Thread exists
indepentent of the main method, so writing a main method has no impact of the number of threads.

Re: About Question enthuware.ocpjp.v8.2.1398 :

Posted: Fri Jun 16, 2023 8:23 am
by dmullandev2
Yeah i took this as ambiguous and if i were to run this from the command line the 'main' thread would start up i.e. 1 new thread. but I see how it's the other.