[Lazarus] Some questions about thread timing and syncrhonization

Frank Church vfclists at gmail.com
Mon Jul 12 14:27:15 CEST 2010


On 12 July 2010 13:06, Michael Schnell <mschnell at lumino.de> wrote:

>  On 07/12/2010 10:22 AM, Frank Church wrote:
>
>>
>> Is the Synchronize method of a thread able to execute when the thread is
>> Suspended?
>>
>> e.g if the following instructions are executed in succession
>>
>>    Synchronize(@DispatchOutput);
>>    Suspend;
>>
>> After the Execute has performed an instance of the thread's main task, I
>> want the to wait until the Synchronize is performed by the main thread, so
>> the Resume is executed in the Synchronize(@DispatchOutput) code. Is that a
>> correct way of working?
>>
>>
> What are you trying to accomplish ?
>
>
I want the thread to be activated only a certain number of times every few
minutes, so if it is not yet time to run the thread or it has run only
recently Resuming should not execute until time is ready.

I also want to stop it if it has been running too long without responding,
or its main routine has not yet returned. I am essentially running command
line programs which may not return their output in good time without
affecting the main thread, network monitoring/polling in an uncertain
networking environment.




> "Synchronize"
>  - Sends a message to the main thread
>  - makes the thread stall
>  - now the main thread preforms the synchronized method
>  - now the main thread makes the thread run again.
>
> This prevents the thread and the main thread use critical resources
> concurrently, but it also prevents the thread from working permanently but
> stalls it for an indefinite amount of time while the main thread is busy
> with other stuff before it gets to doing the synchronized method.
>
> "Suspend" just makes the thread stop and makes it wait for some other
> thread  to wake it.
>
> So the use of "Synchronize" and "Suspend" is unrelated.
>
> -Michael
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Frank Church

=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100712/6779a748/attachment-0004.html>


More information about the Lazarus mailing list