 STYLE="margin-left: 3.01cm">To wait for <I>x</I> to
become greater than <I>y</I> with a timeout of 5 seconds, do: 
</BLOCKQUOTE>
<PRE STYLE="margin-left: 1.01cm">struct timeval now;
struct timespec timeout;
int retcode;
pthread_mutex_lock(&amp;mut);
gettimeofday(&amp;now);
timeout.tv_sec = now.tv_sec + 5;
timeout.tv_nsec = now.tv_usec * 1000;
retcode = 0;
while (x &lt;= y &amp;&amp; retcode != ETIMEDOUT) {
        retcode = pthread_cond_timedwait(&amp;cond, &amp;mut, &amp;timeout);
}
if (retcode == ETIMEDO