[Lazarus] A few questions on threads

Lukasz Sokol el.es.cr at gmail.com
Tue Oct 4 15:36:25 CEST 2011


On 04/10/2011 14:24, Mark Morgan Lloyd wrote:
> michael.vancanneyt at wisa.be wrote:
>> On Tue, 4 Oct 2011, Mark Morgan Lloyd wrote:
>> 
>>> michael.vancanneyt at wisa.be wrote:
>>> 
>>>>> Suspend and Resume have been deprecated, and I want to know
>>>>> how a thread can be suspended.
>>>> 
>>>> There is - to my knowledge - no safe way of doing so.
>>> 
>>> Can a thread safely suspend itself, subject to an external
>>> resume? If not, what is the "official" alternative?
>> 
>> A thread can always suspend itself. It's the suspend by another
>> thread that is dangerous.
> 
> Thanks for that Michael. I've got a thread which runs for a stretch
> in the background to query a database (to avoid a UI glitch), then
> suspends itself until it's kicked back into life by the main thread
> approx 30 seconds later. Appears reliable on all tested platforms.
> 
> Put another way, I can see the argument for restricting access to
> Suspend but I hope nobody has got plans to eliminate it completely.
> 

I think it'll do just fine to put Suspend into strict private section so no
outside module can call it...

L.





More information about the Lazarus mailing list