About Question enthuware.ocpjp.v7.2.1382 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
tn1408
Posts: 28
Joined: Wed Dec 04, 2013 7:57 pm
Contact:

About Question enthuware.ocpjp.v7.2.1382 :

Post by tn1408 »

Hello,

If the question asks how many running threads are there in this program when run, would it be 3 (main, tc, and the thread created with tc.new Runner())?
Or would it be 2: main and the thread created with tc.new Runner() ?

Thanks,

Tony,

tn1408
Posts: 28
Joined: Wed Dec 04, 2013 7:57 pm
Contact:

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

Post by tn1408 »

Never mind

I got it, using Thread.activeCount()
Thanks,

Tony,

Elmcrest
Posts: 12
Joined: Sat Apr 20, 2013 10:06 am
Contact:

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

Post by Elmcrest »

@Tony: Thread.activeCount() returns 2 because only one of the two created Thread objects is actually started. (the other one is the main thread)

Besides that, I'm still not sure about this question and the correct answer "2". Isn't the main thread a Thread object which is created automatically for you each time you start a java application? And wouldn't you have to count this Thread instance too, the correct answer therefor being "3"?

Kind regards

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

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

Post by admin »

You are right. The main thread is also a thread. But that is not the only thread created automatically. THe JVM could create other threads also for example a GC thread.
The question is asking about the threads created by the program. The problem statement has now been updated to make it clear.

thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests