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,
About Question enthuware.ocpjp.v7.2.1382 :
Moderators: Site Manager, fjwalraven
-
- Posts: 28
- Joined: Wed Dec 04, 2013 7:57 pm
- Contact:
-
- Posts: 28
- Joined: Wed Dec 04, 2013 7:57 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1382 :
Never mind
I got it, using Thread.activeCount()
Thanks,
Tony,
I got it, using Thread.activeCount()
Thanks,
Tony,
-
- Posts: 12
- Joined: Sat Apr 20, 2013 10:06 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1382 :
@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
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
-
- Site Admin
- Posts: 10075
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1382 :
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.
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.
Who is online
Users browsing this forum: No registered users and 12 guests