Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24881
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-08-02 11:34 -0700 |
| References | <8fe57dc2-a323-4821-941c-4036663cbce5@googlegroups.com> <w8SdneFLYoQ8bGbMnZ2dnUVZ8jKdnZ2d@bt.com> |
| Message-ID | <271335f6-4f91-4f2a-bf64-6925be460c8e@googlegroups.com> (permalink) |
| Subject | Re: What is so bad aboud Thread.stop() ? |
| From | taqmcg@gmail.com |
On Friday, August 2, 2013 1:50:02 PM UTC-4, Chris Uppal wrote: > taqmcg@gmail.com wrote: > > > The use of Thread.stop() is strongly deprecated, but I'm a bit confused > > by the explanation given in the documentation: (e.g., > >[...] > > So what is the big hullaballoo about? > > > I suspect (modulo my other suspicion that you can't rely on exactly what > Thread.stop() actually does in an actual implementation) that /if/ there is no > mutable state shared with the rest of the program, then it might be OK. > Problem is: there's not a lot of point in a thread that shares /no/ state with > the rest of the program. If it's doing some computation (your? example of an > untrusted regexp engine for instance) then it has to get the answer back to the > calling thread somehow, and that is problematic. Maybe there are some simple > (in the sense of unsophisticated) mechanisms -- the calling thread polling a > volatile variable perhaps (though I have doubts about the semantics of that: > does reading a volatile variable guarantee that the data /referenced/ by that > variable are consistent ? My reading of the JLS doesn't find an answer to that > question). But, say, stop()-ing a thread that is writing to a shared queue is a > no-no. > I don't think you need to do anything particularly dramatic or even necessarily unusual to make separate out the thread-that-may-be-stopped's objects from the general ruck. E.g., while the thread is running it works only on objects it creates. Only when it finishes successfully does the monitor thread use its results. If the thread fails, they are just tossed out. I don't think there is a problem with the stoppable thread having readonly access to data shared with the monitor. You might get some kind of deadlock issue, but that's just general multithreading. Should it have a lock on a shared object when it is killed, then if it has only readonly access, it won't be leaving the locked object in a damaged state when the monitor is released. [AFAICT] > > /If/ you know that the thread is in a fixed, stable, state then you can > probably kill it (assuming the state is suitable), but what about the > end-points -- just as it is entering or leaving that state. I find it > difficult to imagine how you could be sure, avoiding race conditions, that it > would be safe to stop() the thread unless your architecture was already such > that implementing an alternative method wouldn't be easier (or at least, no > harder -- and easier to justify to your peers ;-) Does the thread need to be fixed or stable? I <think> I only need to have it isolated. That's part of what I'm trying to find out. And unless and until I kill it, I can communicate with it using any standard method for interthread communication (e.g., shared objects). That is much more difficult were I using a separate JVM as some have suggested. You mention elsewhere that you're concerned that Thread.stop() might be only partially or imperfectly implemented. That would certainly be an issue. That would be the kind of 'magical' issue that a programmer simply can't get around. However the documentation I've seen suggests that it is the danger of the method, not the quality of the implementation that is an issue. In any case, it certainly seems like the deprecation has done its job of keeping people from trying it out! Regards, 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