www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Suspend/Interrupt threads

reply Nrgyzer <nrgyzer gmail.com> writes:
Hey,

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

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.


Thanks in advance!
Jan 30 2011
parent Sean Kelly <sean invisibleduck.org> writes:
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.
Jan 30 2011