Function ThreadWait() Foundation

Waits for the termination of one thread

ThreadWait( <aThreads> , ;
           [<nTimeOut>], ) --> oThread | NIL
<aThreads> is an array whose elements contain Thread objects. The current thread waits for the termination of one or all of the corresponding threads. The number of elements in <aThreads> is limited to the value of the constant THREAD_WAIT_MAX from THREAD.CH.
<nTimeOut> specifies the maximum amount of time the current thread will wait for the termination of other threads. The unit is 1/100th of a second. The default value is 0 and this causes the current thread to wait infinitely until one Thread object in <aThreads> has finished with executing code. If a value > 0 is specified for <nTimeOut> and no thread has terminated within this period of time, the current thread resumes progam execution.

If one thread terminates within the time limit defined with <nTimeOut>, the function returns the corresponding Thread object. Otherwise, the return value is NIL.


The function ThreadWait() causes the current thread to wait until one thread from a number of threads has terminated. Compared to the :synchronize() method of the Thread class, the function has the advantage that the current thread does not need to wait for a particular thread, but rather can wait for any thread from a number of threads. Note that the number of threads the current thread can wait for is limited to the constant THREAD_WAIT_MAX by the operating system.


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.