Method Thread():synchronize() Foundation
Synchronizes a second thread with the current thread.
:synchronize( <nTimeOut> ) --> lSuccess
When the program code of a second thread has completed its processing following :synchronize(), the method returns the value .T. (true). If the return value is .F. (false), the process in the other thread could not be completed within the specified time interval.
The method :synchronize() allows the current thread to be synchronized with other threads. The current thread waits for termination of the execution of a thread managed by a Thread object. Generally, this method is only needed when threads whose results are dependent on each other are run within an Xbase++ application. For example, part of a statistic might be calculated in thread A while another part of the same statistic is calculated in thread B. Before the complete result can be displayed, both threads must be finished so that thread A can take the entire result into consideration. If thread B needs more time for calculation than thread A, thread A may need to wait for thread B. In this case, the message :synchronize() would be sent to the Thread object managing thread B within thread A.
DO WHILE .NOT. oThreadB:synchronize(1)
<programm code>
ENDDO
/* or */
oThreadB:synchronize(0)
Both approaches cause the program in the current thread to be continued only after thread B has finished. The first possibility uses a loop that is exited only when the second thread has ended. In the second case, the current thread is stopped until thread B terminates. During this period, processor time is allocated only to thread B. The current thread resumes when thread B has terminated.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.