About Question enthuware.ocpjp.v8.2.1398 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Joost86
Posts: 2
Joined: Sat Jan 11, 2020 5:31 pm
Contact:

About Question enthuware.ocpjp.v8.2.1398 :

Post by Joost86 »

Is the main method not creating a thread? In that case, '1 new thread is created' would be true, right?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

No, main method is not creating a thread. Which line of code in main method do you think is creating a thread?
If you like our products and services, please help us by posting your review here.

Joost86
Posts: 2
Joined: Sat Jan 11, 2020 5:31 pm
Contact:

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

Post 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/

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

fukThe
Posts: 1
Joined: Sat Jan 09, 2021 8:35 am
Contact:

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

Post 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.

dmullandev2
Posts: 2
Joined: Fri Apr 28, 2023 6:45 am
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 31 guests