procedure Queue(AMethod: TThreadMethod); overload;
procedure Queue(AThreadProc: TThreadProcedure); overload;
class procedure Queue(AThread: TThread; AMethod: TThreadMethod); overload;
class procedure Queue(AThread: TThread; AThreadProc: TThreadProcedure); overload;
Queue
causes the call specified by the parameter aMethod
run using the main segment(main thread), thus avoiding conflicts between multiple threads. To thread is passed by the current parameter AThread
.
TThread.Queue
it is recommended to use in situations where you have no statement if the method to be used is thread-safe.
The image below illustrates how this is done.
Image credit: huddled.with
TThread.Queue
is comparable to the method Synchronize
but with a single exception, in relation to thread current, when using the Synchronize
to thread is suspended until the method is executed in the main segment, on the other hand, when using TThread.Queue
the execution of thread is permitted to continue.