java.util.concurrent.LinkedBlockingQueue.fullyUnlock()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中java.util.concurrent.LinkedBlockingQueue.fullyUnlock()方法的一些代码示例,展示了LinkedBlockingQueue.fullyUnlock()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedBlockingQueue.fullyUnlock()方法的具体详情如下:
包路径:java.util.concurrent.LinkedBlockingQueue
类名称:LinkedBlockingQueue
方法名:fullyUnlock

LinkedBlockingQueue.fullyUnlock介绍

[英]Unlocks to allow both puts and takes.
[中]

代码示例

代码示例来源:origin: robovm/robovm

public String toString() {
  fullyLock();
  try {
    Node<E> p = head.next;
    if (p == null)
      return "[]";
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {
      E e = p.item;
      sb.append(e == this ? "(this Collection)" : e);
      p = p.next;
      if (p == null)
        return sb.append(']').toString();
      sb.append(',').append(' ');
    }
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Returns {@code true} if this queue contains the specified element.
 * More formally, returns {@code true} if and only if this queue contains
 * at least one element {@code e} such that {@code o.equals(e)}.
 *
 * @param o object to be checked for containment in this queue
 * @return {@code true} if this queue contains the specified element
 */
public boolean contains(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> p = head.next; p != null; p = p.next)
      if (o.equals(p.item))
        return true;
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Saves this queue to a stream (that is, serializes it).
 *
 * @serialData The capacity is emitted (int), followed by all of
 * its elements (each an {@code Object}) in the proper order,
 * followed by a null
 */
private void writeObject(java.io.ObjectOutputStream s)
  throws java.io.IOException {
  fullyLock();
  try {
    // Write out any hidden stuff, plus capacity
    s.defaultWriteObject();
    // Write out all elements in the proper order.
    for (Node<E> p = head.next; p != null; p = p.next)
      s.writeObject(p.item);
    // Use trailing null as sentinel
    s.writeObject(null);
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Returns an array containing all of the elements in this queue, in
 * proper sequence.
 *
 * <p>The returned array will be "safe" in that no references to it are
 * maintained by this queue.  (In other words, this method must allocate
 * a new array).  The caller is thus free to modify the returned array.
 *
 * <p>This method acts as bridge between array-based and collection-based
 * APIs.
 *
 * @return an array containing all of the elements in this queue
 */
public Object[] toArray() {
  fullyLock();
  try {
    int size = count.get();
    Object[] a = new Object[size];
    int k = 0;
    for (Node<E> p = head.next; p != null; p = p.next)
      a[k++] = p.item;
    return a;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: robovm/robovm

return a;
} finally {
  fullyUnlock();

代码示例来源:origin: robovm/robovm

/**
 * Removes a single instance of the specified element from this queue,
 * if it is present.  More formally, removes an element {@code e} such
 * that {@code o.equals(e)}, if this queue contains one or more such
 * elements.
 * Returns {@code true} if this queue contained the specified element
 * (or equivalently, if this queue changed as a result of the call).
 *
 * @param o element to be removed from this queue, if present
 * @return {@code true} if this queue changed as a result of the call
 */
public boolean remove(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> trail = head, p = trail.next;
       p != null;
       trail = p, p = p.next) {
      if (o.equals(p.item)) {
        unlink(p, trail);
        return true;
      }
    }
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns {@code true} if this queue contains the specified element.
 * More formally, returns {@code true} if and only if this queue contains
 * at least one element {@code e} such that {@code o.equals(e)}.
 *
 * @param o object to be checked for containment in this queue
 * @return {@code true} if this queue contains the specified element
 */
public boolean contains(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> p = head.next; p != null; p = p.next)
      if (o.equals(p.item))
        return true;
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: ibinti/bugvm

public String toString() {
  fullyLock();
  try {
    Node<E> p = head.next;
    if (p == null)
      return "[]";
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {
      E e = p.item;
      sb.append(e == this ? "(this Collection)" : e);
      p = p.next;
      if (p == null)
        return sb.append(']').toString();
      sb.append(',').append(' ');
    }
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: MobiVM/robovm

public String toString() {
  fullyLock();
  try {
    Node<E> p = head.next;
    if (p == null)
      return "[]";
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {
      E e = p.item;
      sb.append(e == this ? "(this Collection)" : e);
      p = p.next;
      if (p == null)
        return sb.append(']').toString();
      sb.append(',').append(' ');
    }
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

public String toString() {
  fullyLock();
  try {
    Node<E> p = head.next;
    if (p == null)
      return "[]";
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {
      E e = p.item;
      sb.append(e == this ? "(this Collection)" : e);
      p = p.next;
      if (p == null)
        return sb.append(']').toString();
      sb.append(',').append(' ');
    }
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns {@code true} if this queue contains the specified element.
 * More formally, returns {@code true} if and only if this queue contains
 * at least one element {@code e} such that {@code o.equals(e)}.
 *
 * @param o object to be checked for containment in this queue
 * @return {@code true} if this queue contains the specified element
 */
public boolean contains(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> p = head.next; p != null; p = p.next)
      if (o.equals(p.item))
        return true;
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns {@code true} if this queue contains the specified element.
 * More formally, returns {@code true} if and only if this queue contains
 * at least one element {@code e} such that {@code o.equals(e)}.
 *
 * @param o object to be checked for containment in this queue
 * @return {@code true} if this queue contains the specified element
 */
public boolean contains(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> p = head.next; p != null; p = p.next)
      if (o.equals(p.item))
        return true;
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns {@code true} if this queue contains the specified element.
 * More formally, returns {@code true} if and only if this queue contains
 * at least one element {@code e} such that {@code o.equals(e)}.
 *
 * @param o object to be checked for containment in this queue
 * @return {@code true} if this queue contains the specified element
 */
public boolean contains(Object o) {
  if (o == null) return false;
  fullyLock();
  try {
    for (Node<E> p = head.next; p != null; p = p.next)
      if (o.equals(p.item))
        return true;
    return false;
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Atomically removes all of the elements from this queue.
 * The queue will be empty after this call returns.
 */
public void clear() {
  fullyLock();
  try {
    for (Node<E> p, h = head; (p = h.next) != null; h = p) {
      h.next = h;
      p.item = null;
    }
    head = last;
    // assert head.item == null && head.next == null;
    if (count.getAndSet(0) == capacity)
      notFull.signal();
  } finally {
    fullyUnlock();
  }
}

相关文章

微信公众号

最新文章

更多