[D-runtime] A mechanism to kill threads

Sean Kelly sean at invisibleduck.org
Wed May 16 14:40:47 PDT 2012


Ah, but that's why we have thread_suspendAll() but no way to suspend only one specific thread.  Because Java exposes Thread.suspend() for a single thread, people seem inclined to call it as a poor man's form of synchronization, with disastrous results.  In fact, this is also why thread_suspendAll() is an extern (C) call rather than exposed as a static method in Thread.  I was trying to make it as obscure as possible while still allowing it to be called by the GC.

On May 16, 2012, at 11:57 AM, 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?
> 
> Regards,
> Alex
> 
> On Wed, May 16, 2012 at 8:47 PM, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
>> On Wednesday, May 16, 2012 19:04:48 Alex Rønne Petersen wrote:
>>> Hi,
>>> 
>>> In my virtual machine, I need to be able to kill daemon threads on
>>> shutdown. The problem is that VM shutdown is *not* tightly coupled to
>>> druntime shutdown; multiple VM instances can run in a process at any
>>> given time, and can be started/stopped whenever. It doesn't appear
>>> like there is any functionality in core.thread to achieve this.
>>> 
>>> Is there any reason we don't have a Thread.kill() function?
>> 
>> Because it's incredibly unsafe? You may have a valid use case for it, but it's
>> _not_ something that you should normally be doing.
>> 
>> - Jonathan M Davis
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime



More information about the D-runtime mailing list