Suspend/Interrupt threads

Sean Kelly sean at invisibleduck.org
Sun Jan 30 12:34:32 PST 2011


Nrgyzer Wrote:

> Hey,
> 
> how can I interrupt/suspend threads in D2? core.thread only provides
> start(), join() and similar, but nothing like interrupt() in JAVA.

Have the thread call sleep() or use a semaphore or mutex.  If you want to suspend a thread and have it be interruptable use a mutex combined with a condition variable (from core.sync).
 
> I have a thread which sleeps for some seconds. Does join() interrupts
> the Thread.sleep()-call? I don't want that the user have to wait some
> seconds because a thread is running, but sleeping.

It doesn't interrupt the sleep() call if the thread is sleeping.  join() simply waits for the thread to terminate normally.


More information about the Digitalmars-d mailing list