About Question enthuware.ocpjp.v7.2.1500 :

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

Moderator: admin

Post Reply
The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

About Question enthuware.ocpjp.v7.2.1500 :

Post by The_Nick »

"You can stop any thread". As far as I know it's only possible to interrupt a thread or handle the interrupt flag with some flow control in order to terminate it.
Do you mean interrupting the thread by using t.interrupt() with "stop any thread"?
What about deamon thread are they stoppable or is the only way to terminate them terminating all the user threads?
Thanks in advance.

The_Nick.

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

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

Post by admin »

There is a stop() method in Thread class, which is deprecated but it is there. It can be used to stop any thread - daemon or not.
HTH,
Paul.

The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

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

Post by The_Nick »

Hi,
You say in the explanation that:
For example, the Garbage Collector thread is useful only if some user thread is running. If all the user threads end then what is the use of GC thread? So the program should end when all the non-daemon threads end.
Does it mean that GC thread is always a deamon thread?
I thought it was not guaranteed.
Thanks in advance.

The_Nick.

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

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

Post by admin »

It is just an example to explain why daemon threads should not keep a program running. But can you please tell me where you saw that GC thread may not be a daemon thread?

thank you,
Paul.

The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

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

Post by The_Nick »

You right, my bad. I think I read only that it's not guaranteed which thread will handle the GC but not what kind of thread. On the other hand I have never read in any official documentation that the GC thread will be surely a daemon thread.
However it makes much more sense thinking that it's a Daemon thread, otherwise what could it be?

Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests