AbstractQueuedSynchronizer::signalNextIfShared源码笔记

static final int WAITING   = 1;          // must be 1
static final int CANCELLED = 0x80000000; // must be negative
static final int COND      = 2;          // in a condition wait


// 如果h的后继节点是共享模式的节点,那么结束它的等待状态
private static void signalNextIfShared(Node h) {
    Node s;
    if (h != null && (s = h.next) != null &&
        (s instanceof SharedNode) && s.status != 0) {
        s.getAndUnsetStatus(WAITING);
        LockSupport.unpark(s.waiter);
    }
}

 

posted @ 2021-03-31 15:07  榆木脑袋0v0  阅读(71)  评论(0)    收藏  举报