[Lazarus] Some questions about thread timing and syncrhonization

Michael Schnell mschnell at lumino.de
Mon Jul 12 14:06:28 CEST 2010


  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 ?

"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




More information about the Lazarus mailing list