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.



First page Back Continue Last page Summary Graphic

… More What Not to Do

  • 1 PRBool dataIsAvailable = PR_FALSE;

  • 2 PR_Lock( lock );

  • 3 if ( !dataIsAvailable )

  • 4 PR_WaitCondVar( cv, PR_INTERVAL_NO_TIMEOUT ); /* Bad! dataIsAvailable may change during wait */

  • 5 /* work on the available data */

  • 6 PR_Unlock( lock );

  • The lock is released during PR_WaitCondvar(). Other threads can change dataIsAvailable. Use the while() loop; test, wait, test again.


Notes: