摘要: /** * Removes and transfers one or all waiters to sync queue. */ private void doSignal(ConditionNode first, boolean all) { while (first != null) { Con 阅读全文
posted @ 2021-04-23 21:49 榆木脑袋0v0 阅读(58) 评论(0) 推荐(0)
摘要: public final void await() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); ConditionNode node = new Condition 阅读全文
posted @ 2021-04-21 21:25 榆木脑袋0v0 阅读(71) 评论(0) 推荐(0)
摘要: // 函数作用: // 1.设定node的各项参数 // 2.将node加入ConditionNode等待队列 // 3.释放当前线程持有的锁 private int enableWait(ConditionNode node) { if (isHeldExclusively()) { // nod 阅读全文
posted @ 2021-04-20 20:32 榆木脑袋0v0 阅读(75) 评论(0) 推荐(0)
摘要: public final boolean release(int arg) { if (tryRelease(arg)) { // 注意,这里signalNext的参数为head,即头结点 // 也就是说线程释放锁后总是会激活等待队列中的第一个节点 signalNext(head); return 阅读全文
posted @ 2021-04-15 15:53 榆木脑袋0v0 阅读(48) 评论(0) 推荐(0)
摘要: public final boolean tryAcquireNanos(int arg, long nanosTimeout) throws InterruptedException { // 如果线程已经被中断则抛中断异常 if (!Thread.interrupted()) { // 首次简单 阅读全文
posted @ 2021-04-15 15:45 榆木脑袋0v0 阅读(97) 评论(0) 推荐(0)
摘要: 此处的acquire方法指AQS内部的私有acquire方法,方法签名为 final int acquire(Node node, int arg, boolean shared, boolean interruptible, boolean timed, long time) static fin 阅读全文
posted @ 2021-04-14 20:54 榆木脑袋0v0 阅读(129) 评论(0) 推荐(0)
摘要: 该文章对Integer类源代码中的重点、难点代码段进行分析。对于源代码中比较简单的部分不再赘述,有需要的可以直接查看源代码。 Integer::stringSize(int x) 计算一个int类型的数值转换成字符串后长度为多少 1 static int stringSize(int x) { 2 阅读全文
posted @ 2021-04-13 15:12 榆木脑袋0v0 阅读(146) 评论(0) 推荐(0)
摘要: // interruptible 为true表示当线程的interrupted标识位被置位时 // 返回一个负数;为false表示不返回一个负数,并重新置位一次interrupted标志位 private int cancelAcquire(Node node, boolean interrupte 阅读全文
posted @ 2021-04-01 17:00 榆木脑袋0v0 阅读(181) 评论(0) 推荐(0)
摘要: /** * Possibly repeatedly traverses from tail, unsplicing cancelled * nodes until none are found. Unparks nodes that may have been * relinked to be ne 阅读全文
posted @ 2021-03-31 15:43 榆木脑袋0v0 阅读(126) 评论(1) 推荐(0)
摘要: static final int WAITING = 1; // must be 1 static final int CANCELLED = 0x80000000; // must be negative static final int COND = 2; // in a condition w 阅读全文
posted @ 2021-03-31 15:07 榆木脑袋0v0 阅读(78) 评论(0) 推荐(0)