java - 并发包下面类的一些疑问
伊谢尔伦
伊谢尔伦 2017-04-18 09:24:09
[Java讨论组]

下面一些注释摘自AbstractQueuedSynchronizer.Node:

/**

  • Status field, taking on only the values:

  • SIGNAL: The successor of this node is (or will soon be)

  • blocked (via park), so the current node must

  • unpark its successor when it releases or

    1. To avoid races, acquire methods must

  • first indicate they need a signal,

  • then retry the atomic acquire, and then,

  • on failure, block.

  • CANCELLED: This node is cancelled due to timeout or interrupt.

  • Nodes never leave this state. In particular,

  • a thread with cancelled node never again blocks.

  • CONDITION: This node is currently on a condition queue.

  • It will not be used as a sync queue node

  • until transferred, at which time the status

  • will be set to 0. (Use of this value here has

  • nothing to do with the other uses of the

  • field, but simplifies mechanics.)

  • PROPAGATE: A releaseShared should be propagated to other

    1. This is set (for head node only) in

  • doReleaseShared to ensure propagation

  • continues, even if other operations have

  • since intervened.

  • 0: None of the above
    *

  • The values are arranged numerically to simplify use.

  • Non-negative values mean that a node doesn't need to

    1. So, most code doesn't need to check for particular

  • values, just for sign.
    *

  • The field is initialized to 0 for normal sync nodes, and

  • CONDITION for condition nodes. It is modified using CAS

  • (or when possible, unconditional volatile writes).

    但是这些状态(粗体)都比较抽象,有比较直白的解释么?或者需要什么知识点才能看懂这些含义

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
PHP中文网

链接描述

链接描述

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号