|
![](/i/fill.gif) |
On 23/10/2010 06:27 PM, Warp wrote:
> Usually threads are ended by exiting the function that was launched by
> the thread...
Yes, usually. But the GHC threading implementation allows you to
forcibly "kill" another thread (by throwing an exception in it, as I say).
It's occasionally useful to do this if the thread performs some kind of
"infinite loop", and it's another thread's job to detect when the loop
should be stopped. You could of course just have a semaphore to signal
to the thread that it should stop now, but if some part of the thread's
loop takes a long time to execute, it might not be convinient to check
the semaphore frequently enough that the thread will stop promptly.
(OTOH, I gather GHC cannot kill a thread except at certain points in the
code, so you can end up with an unkillable thread anyway...)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |