POV-Ray : Newsgroups : povray.off-topic : Programming language discussion : Re: Programming language discussion Server Time
4 Sep 2024 01:21:53 EDT (-0400)
  Re: Programming language discussion  
From: Orchid XP v8
Date: 23 Oct 2010 13:33:03
Message: <4cc31c4f$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.