In effect it borrows time from the main VCL thread to do this. This does not work arbitrarily between threads. If you have two non-VCL threads, X and Y, you can not call synchronize in X alone and then modify data stored in Y. It is necessary to call synchronize from both threads when reading or writing the shared data. in effect, this means that the data is modified by the main VCL thread, and all the other threads synchronize to the main VCL thread every time they need to access this data This is workable, but inefficient, especially if the main thread is busy:. every time the two threads need to communicate, they have to wait for a third thread to become idle Later on, we shall see how to. Control Concurrency Between the Threads and have themunicate Directly.
TTHREAD.SYNCHRONIZE can prevent threads conflicts with shared data access, and its implementation method is that when the sub-thread performs access to the shared resource, the sub-thread is immediately hanging, waiting for the main thread to be idle in the main thread. Execute the code that accesses the shared resource, the code is completed after the main thread is executed, and the main thread returns the original state, and the sub-thread continues to run. In summary, the code in the sub-thread is actually executed in the main thread, and it is substantially sent to the main thread, inform it which function should be called. The problem is that when multiple sub-threads are synchronized, according to this method, you must wait for the main thread to be idle, and there is no need to get the power of the main thread, which is not necessary, the efficiency is also low.