Page 1 of 1

About Question enthuware.ocpjp.v8.2.1382 :

Posted: Tue Oct 06, 2015 12:12 pm
by mrmuiz
This question showed up in the "Advanced Class Design", shouldn't it be under "Threads" section?

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

Posted: Tue Oct 06, 2015 10:21 pm
by admin
It could be considered to be belonging to Threads topic because of the reference to Thread class but it has been put in Nested classes topic because it involves instantiating and using a nested class. It does not present any threading related issues either.

HTH,
Paul.

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

Posted: Fri Jul 08, 2016 9:01 am
by RAZER-KIEV
Does an invocation of psvm method by JVM not creates new Thread object?

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

Posted: Fri Jul 08, 2016 11:00 am
by admin
Yes, but from the certification perspective, we are concerned only with the threads created by our code.

HTH,
Paul.

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

Posted: Fri Jul 08, 2016 1:19 pm
by RAZER-KIEV
So, I think that question "How many Thread objects are created BY THE ABOVE PROGRAM when it is compiled and run?" looks like ambiguously if we have 3 Threads generated by JVM.

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

Posted: Fri Jul 08, 2016 9:27 pm
by admin
It is not ambiguous. The program that is given in the question creates only 2 threads.
Considering threads created by JVM doesn't make any sense here. It may create many threads. For example, it will create one for GC as well. If you take a thread dump of this java program, you may see 8-9 or more threads created.

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

Posted: Mon Oct 16, 2017 4:00 am
by horst1a
I am puzzled by the explanation. It says, TestClass is also a thread, because it extends Thread.
If it did not extend Thread, wouldn't we have 2 threads,nevertheless, because the main-method of TestClass is
creating its own thread ?

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

Posted: Mon Oct 16, 2017 10:43 pm
by admin
The question is asking about the number of Thread objects that are created by the given code. It is not asking about number of "threads" created (irrespective of whether by program or the jvm).

Creation of a Thread object and "creating a thread" are two different things. A thread (with small t) is created by the JVM when you call start on a Thread object. Having a Thread object doesn't necessarily mean there is a thread of execution.