You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is
highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If
there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.
Skip to main content
First page Back Continue Last page Summary Graphic
Using Condition Variables
1 PRIntn data = 0; /* Thread A */
2 PRLock *lock = PR_NewLock();
3 PRCondVar *cvar = PR_NewCondVar(lock);
4 PR_Lock(lock);
5 while( data == 0 )
6 PR_WaitCondVar( cvar, timeout );
/* lock released while blocked. */
/* re-locked at fall through */
7 data = 0; /* satisfy Thread Bs condition */
8 PR_NotifyCondVar( cvar );
9 PR_Unlock( lock );
Notes: