Water 5-Concurrent Programming-Thread
method thread.wait_until_done
Contract
Return typewob
Parameter keyDefault valueType
a_threadreqthread
max_timeoutoptinteger
Water Contract
<method thread.wait_until_done
  a_thread   =req=thread
  max_timeout=opt=number.integer/>
wait_unitl_done is passed an argument of another thread. The current thread pauses as long as the other thread is not done. Once the other thread is done, the current thread resumes processing. If the passed-in thread is already done when the call to wait_until_done is made, then that call to wait_until_done does nothing. In the below example, we:
    Create a new thread that will take at least a couple of seconds.Print begin.Start the new thread running.Wait for the new thread to be done.print end.
<thread id="myt"> 
    <echo "before sleep"/> 
    thread.<wait_until_time a_time=300/>
    <echo "after sleep"/>
   </thread>
<echo "begin"/>
thread.of.myt.<start/>
thread.<wait_until_done a_thread=thread.of.myt/>
<echo "end"/>
"end"
Imagine that instead of just printing and waiting, our new thread was actually a call to a web service. Also imagine that we have several web services to call. We can create and start each call to a web service within its own thread. They will compute in parallel using the web and the remote server for distributed processing. After we make such calls, we could wait_until_done for each of our new threads. When our last call to wait_until_done returns, all of our web services will be complete and we can process their results. Note that it matter little time-wise how we order our calls to the web services or how we order the waiting for them to be done. It just matters that we start each thread before waiting for any of them.