[D-runtime] A mechanism to kill threads
David Simcha
dsimcha at gmail.com
Wed May 16 14:19:02 PDT 2012
For the sake of argument, what are the most non-obvious reasons why killing
threads is bad? The ones I can think of are because the thread may be in
the middle of doing something important and bad things will happen if it's
interrupted and because the thread might hold resources that will never get
freed if it's killed before it gets to free them.
I was thinking at one point that I wanted a kill() primitive when I was
designing std.parallelism, but I don't remember why I wanted it and
obviously I've managed to do without it. Is it ok to kill threads if
they're not doing useful work at the time and they're not holding onto any
resources that will never get freed if you kill them?
On Wed, May 16, 2012 at 5:04 PM, Jonathan M Davis <jmdavisProg at gmx.com>wrote:
> On Wednesday, May 16, 2012 20:57:15 Alex Rønne Petersen wrote:
> > Of course it's unsafe, but no less than arbitrarily suspending a
> > thread. Once you've suspended a thread, you may as well kill it.
> > You've effectively halted it anyway. We have lots of unsafe primitives
> > in core.thread already (and my critical regions and cooperative
> > suspension patches add even more!).
> >
> > Is there anything speaking against adding this to core.thread with a
> > big fat "THIS IS UNSAFE" warning?
>
> Well, I wasn't saying that it's necessarily the case that we shouldn't add
> it.
> I was pointing out that it's a very unsafe thing to do and rarely needed
> such
> that it's not exactly surprising that it hasn't been added previously. If
> there's a real use case for it, it makes sense to add it given that it _is_
> something that's platform dependent, and part of the whole point of Thread
> is
> to provide a platform-independent API for handling threads. It probably
> _should_ have a big fat warning on it though, given that not all developers
> seem to get how insanely bad it is to kill a thread (at least, that seems
> to
> be the case given some thread-related questions I've seen in the past).
>
> - Jonathan M Davis
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d-runtime/attachments/20120516/001feabc/attachment.html>
More information about the D-runtime
mailing list