"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.
About Question enthuware.ocpjp.v7.2.1500 :
Moderator: admin
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1500 :
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.
HTH,
Paul.
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1500 :
Hi,
You say in the explanation that:
I thought it was not guaranteed.
Thanks in advance.
The_Nick.
You say in the explanation that:
Does it mean that GC thread is always a deamon thread?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.
I thought it was not guaranteed.
Thanks in advance.
The_Nick.
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1500 :
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.
thank you,
Paul.
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1500 :
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.
However it makes much more sense thinking that it's a Daemon thread, otherwise what could it be?
Thanks.
Who is online
Users browsing this forum: No registered users and 9 guests