Condition Variables 编辑

This chapter describes the API for creating and destroying condition variables, notifying condition variables of changes in monitored data, and making a thread wait on such notification.

Conditions are closely associated with a single monitor, which typically consists of a mutex, one or more condition variables, and the monitored data. The association between a condition and a monitor is established when a condition variable is created, and the association persists for its life. In addition, a static association exists between the condition and some data within the monitor. This data is what will be manipulated by the program under the protection of the monitor.

A call to /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_WaitCondVar causes a thread to block until a specified condition variable receives notification of a change of state in its associated monitored data. Other threads may notify the condition variable when changes occur.

For an introduction to NSPR thread synchronization, including locks and condition variables, see Introduction to NSPR.

For reference information on NSPR locks, see Locks.

NSPR provides a special type, /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRMonitor, for use with Java. Unlike a mutex of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRLock, which can have multiple associated condition variables of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRCondVar, a mutex of type /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRMonitor has a single, implicitly associated condition variable. For information about /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRMonitor, see /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/Monitors.

Condition Variable Type

Condition Variable Functions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:60 次

字数:4015

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文