Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24952

Re: What is so bad aboud Thread.stop() ?

From blmblm@myrealbox.com <blmblm.myrealbox@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: What is so bad aboud Thread.stop() ?
Date 2013-08-11 17:46 +0000
Organization None
Message-ID <b6q109Fsua7U1@mid.individual.net> (permalink)
References <8fe57dc2-a323-4821-941c-4036663cbce5@googlegroups.com> <271335f6-4f91-4f2a-bf64-6925be460c8e@googlegroups.com> <xoednYWz9K2jUGHMnZ2dnUVZ8m-dnZ2d@bt.com> <ede0c691-85eb-4977-8644-27078248ed9d@googlegroups.com>

Show all headers | View raw


In article <ede0c691-85eb-4977-8644-27078248ed9d@googlegroups.com>,
 <taqmcg@gmail.com> wrote:
> On Saturday, August 3, 2013 5:28:41 AM UTC-4, Chris Uppal wrote:
> > taqmcg@gmail.com wrote:
> > 
> > 
> > 
> > > unless and until I kill it, I can communicate with it using any standard
> > > method for interthread communication (e.g., shared objects).
> > 
> > But that's my point here (or one of them): The objects you use to communicate
> > with the other thread are necessarily both shared and mutable by that thread
> > (or else how can it use them to communicate ?).  Given that, it's hard to make
> > /those objects/ safe if you are considering killing the other thread
> > asynchronously -- since it may be in the middle of /using/ (modifying) them 
> > when it's killed.
> 
> You can use objects that are readonly to the stoppable thread to send
> information to that thread, and use objects that are read by the
> monitor (or other threads) only after the thread has successfully
> finished (or at least completed the tasks during which it may be
> stopped) to get information back.  The fact that I might have stopped
> the thread in some circumstances doesn't mean I can't use objects
> created by it when I do let it finish.
> 

That *sounds* plausible ....  But it occurs to me that assigning values
to variable is no longer a simple matter -- with smart compilers and
caches and so forth, it's hard to be sure when the value will actually
be visible to other threads, which is presumably why the Java memory
model (with its "happens before" and so forth) exists.  Can someone who
knows that model comment on how it might apply here?

> 
> > 
> > I'm not saying it's impossible to create an efficient, Thread-stop()-safe, 
> > shared communication channel, but I don't think it's easy (polling is probably
> > the best bet).  And I doubt if you'll find ant *semi-)"official" ones -- why
> > would anyone bother when Thread.stop() is so widely shunned ?
> > 
> > 
> I wasn't really thinking about a dialog between threads, but that
> shouldn't be too hard either.  Suppose you use an object X to carry on
> the dialog, mutable by both threads.  No special problems before you
> stop the thread.  After stopping a thread you recognize that X is
> damaged and throw it away.  Any object that the monitor thread can
> access that could have been mutated by the stopped thread is suspect,
> but simply discarding them is easy enough.  I don't think a damaged
> object has cooties and affects a program just by being there.  It has
> to be used in some way that lets the damaged state manifest itself.
> That could be subtle (say it does something in its finalizer), but it
> should be knowable.
> 
> > 
> >     -- chris
> 
> Thanks for your comments.  I'm playing the devil's advocate here to
> try to draw out specifics of why it would be so difficult to handle
> the consequences of stopping a thread, but since it has been, as you
> say, widely shunned, it doesn't seem like there is too much experience
> actually using it.  Of course the fact that people haven't had to use
> it does mean that at least most of the time there are alternatives,
> though some (e.g., a separate JVM) may be very heavyweight.
> 

-- 
B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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