Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24867
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-08-01 07:38 -0700 |
| References | <8fe57dc2-a323-4821-941c-4036663cbce5@googlegroups.com> <51f93cc4$0$291$14726298@news.sunsite.dk> <a6efb240-0426-4019-896e-2f41cf74a26a@googlegroups.com> |
| Message-ID | <699768ec-b0b7-4752-a373-b58b8a39e32e@googlegroups.com> (permalink) |
| Subject | Re: What is so bad aboud Thread.stop() ? |
| From | usvirtualobservatory@gmail.com |
On Wednesday, July 31, 2013 5:13:25 PM UTC-4, Lew wrote:
...
> >> As I understand this, the ThreadDeath exception is treated exactly as
>
> >> any other exception -- finally blocks are honored, it can even be
>
>
>
> Except for the differences mentioned in the passage you cited.
>
That's the crux of my confusion. It is my understanding that the propagation
of the thread death is exactly the same as for any other exception. So
ThreadDeath behaves exactly as any other exception that might be triggered.
The only difference is that it can get triggered anywhere. None of the items
you have in litany of 'bad' things is different for other exceptions.
>
>
> >> caught -- that might be thrown unexpectedly. E.g., if we got an
>
> >> OutOfMemoryError or we happen to explicitly throw a RuntimeException
>
> >> we're going to see exactly the same behavior with monitors released
>
> >> progressively as we go up the stack. It's certainly easy enough to
>
>
>
> Who said that 'Thread.stop()' release monitors progressively or goes up the stack?
The text I quoted. So Oracle (nee Sun).
>
>
>
> >> catch and rethrow the ThreadDeath in its run method if I really want
>
> >> to log it and address the one difference.
>
>
>
> Who will catch the exception?
>
The code being stopped. E.g., I could have my
thread defined in a class Z like:
class Z implements Runnable {
public void run() {
try {
... code
} catch (ThreadDeath e) {
log(e);
throw e;
}
}
}
>
>
> >> So what is the big hullaballoo about? Is there something special
>
>
>
> Broken code that fails silently at unexpected times in ways that are difficult to detect,
>
> let alone diagnose, that causes your program to be useless but you can't fix it.
>
>
>
> >> going on here with Thread.stop(), or is this just a specific instance
>
>
>
> Yes.
What is it that is special?
>
>
>
> >> of the fact the we should be very careful whenever a thread has been
>
> >> stopped by an unexpected exception?
>
>
....
>
>
> >> Thread.stop() might be called at any time in the to-be-stopped
>
> >> thread, and that might be an issue, but at least in principle the
>
> >> thread that issues the stop could check the to-be-stopped thread and
>
> >> only stop it at 'appropriate' points where appropriate is defined by
>
> >> the user.
>
>
>
> No, because the starting thread has no insight into where the started thread is,
>
> or what points are appropriate, except for critical sections, which are for shit when
>
> a 'stop()' call destroys things.
But as the example shows its easy to arrange things so that the stopping
thread can know something. Until I actually call Thread.stop, all the normal mechanisms by which thread's communicate can be invoked. Does it have to be fine grained in some way that can't be done using these? Why?
>
>
>
> >> E.g., suppose I have some concern that a piece of code that I'm about
>
> >> to run might have an infinite loop in it (say I'm testing somebody
>
> >> else's regular expression parser with lots of different RE's), but
>
> >> it's not going to allocate any external resources (e.g., files, DB
>
> >> connections). I could set/clear a flag as I enter and leave the
>
> >> suspect code. Could I safely monitor this thread in another thread.
>
> >> After say 100 seconds if a given expression hasn't parsed can the
>
> >> monitor thread invoke a Thread.stop() safely if my flag shows that
>
> >> the RE thread is caught in the parser?
>
>
>
> No.
Why not? By hypothesis say there are no subthreads created, no files, no external connections. I can ensure that no objects created in the RE code thread are going to be accessed by the monitor thread or any other -- at least in the code I control. We're just going to throw them away. What is it that will trip me up?
>
>
>
> > I think this part is the critical part
>
> >
>
> > # If any of the objects previously protected by
>
> > # these monitors were in an inconsistent state, other threads
>
> > # may now view these objects in an inconsistent state.
>
> >
>
> > There are cases where using it may result in problems.
>
> >
>
> > There may also be cases where it will work fine. But that is
>
> > not sufficient to consider something "safe".
>
> >
>
> > Go with the recommended approach of having the external
>
> > thread set a flag and the thread itself read it and close
>
> > down.
>
>
>
> Buy and closely study _Java Concurrency in Practice_ by Brian Goetz, et al. You will
>
> not get the in-depth understanding you need from a newsgroup.
>
>
>
> --
>
> Lew
Maybe, but the discussion in a newsgroup can be quite informative.
Thanks for you comments,
Tom
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-07-31 06:36 -0700
Re: What is so bad aboud Thread.stop() ? Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-07-31 18:31 +0200
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-07-31 12:35 -0400
Re: What is so bad aboud Thread.stop() ? Lew <lewbloch@gmail.com> - 2013-07-31 14:13 -0700
Re: What is so bad aboud Thread.stop() ? usvirtualobservatory@gmail.com - 2013-08-01 07:38 -0700
Re: What is so bad aboud Thread.stop() ? Lew <lewbloch@gmail.com> - 2013-08-01 14:07 -0700
Re: What is so bad aboud Thread.stop() ? Steven Simpson <ss@domain.invalid> - 2013-08-01 23:15 +0100
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-01 16:16 -0700
Re: What is so bad aboud Thread.stop() ? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-08-02 18:35 +0100
Re: What is so bad aboud Thread.stop() ? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-08-03 19:21 -0700
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-02 21:58 -0400
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-03 05:08 -0700
Re: What is so bad aboud Thread.stop() ? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-07-31 21:09 -0700
Re: What is so bad aboud Thread.stop() ? usvirtualobservatory@gmail.com - 2013-08-01 08:00 -0700
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-01 11:25 -0400
Re: What is so bad aboud Thread.stop() ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-01 11:49 -0400
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-02 21:51 -0400
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-01 09:30 -0700
Re: What is so bad aboud Thread.stop() ? markspace <markspace@nospam.nospam> - 2013-08-01 10:01 -0700
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-02 21:55 -0400
Re: What is so bad aboud Thread.stop() ? Sven Köhler <remove-sven.koehler@gmail.com> - 2013-08-01 18:28 +0300
Re: What is so bad aboud Thread.stop() ? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-08-02 18:50 +0100
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-02 11:34 -0700
Re: What is so bad aboud Thread.stop() ? Arne Vajhøj <arne@vajhoej.dk> - 2013-08-02 22:04 -0400
Re: What is so bad aboud Thread.stop() ? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-08-03 10:10 +0100
Re: What is so bad aboud Thread.stop() ? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-08-03 10:28 +0100
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-03 05:00 -0700
Re: What is so bad aboud Thread.stop() ? blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2013-08-11 17:46 +0000
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-13 11:47 -0700
Re: What is so bad aboud Thread.stop() ? blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2013-08-13 20:18 +0000
Re: What is so bad aboud Thread.stop() ? Patricia Shanahan <pats@acm.org> - 2013-08-13 13:51 -0700
Re: What is so bad aboud Thread.stop() ? blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2013-08-14 22:42 +0000
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-13 14:10 -0700
Re: What is so bad aboud Thread.stop() ? Lew <lewbloch@gmail.com> - 2013-08-13 15:22 -0700
Re: What is so bad aboud Thread.stop() ? Arivald <NOSPAMarivald@interia.pl> - 2013-08-14 01:08 +0200
Re: What is so bad aboud Thread.stop() ? markspace <markspace@nospam.nospam> - 2013-08-13 16:45 -0700
Re: What is so bad aboud Thread.stop() ? Arivald <NOSPAMarivald@interia.pl> - 2013-08-14 08:42 +0200
Re: What is so bad aboud Thread.stop() ? Marcel Müller <news.5.maazl@spamgourmet.org> - 2013-08-14 09:48 +0200
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-14 08:55 -0700
Re: What is so bad aboud Thread.stop() ? markspace <markspace@nospam.nospam> - 2013-08-14 19:10 -0700
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-15 06:51 -0700
Re: What is so bad aboud Thread.stop() ? Lew <lewbloch@gmail.com> - 2013-08-15 17:35 -0700
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-16 06:30 -0700
Re: What is so bad aboud Thread.stop() ? blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2013-08-14 22:43 +0000
Re: What is so bad aboud Thread.stop() ? taqmcg@gmail.com - 2013-08-15 12:12 -0700
csiph-web