java.lang.Thread.holdsLock()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(165)

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

Thread.holdsLock介绍

[英]Returns true if and only if the current thread holds the monitor lock on the specified object.

This method is designed to allow a program to assert that the current thread already holds a specified lock:

assert Thread.holdsLock(obj);

[中]当且仅当当前线程持有指定对象上的监视器锁时,返回true。
此方法旨在允许程序断言当前线程已持有指定的锁:

assert Thread.holdsLock(obj);

代码示例

代码示例来源:origin: square/okhttp

void put(RealConnection connection) {
 assert (Thread.holdsLock(this));
 if (!cleanupRunning) {
  cleanupRunning = true;
  executor.execute(cleanupRunnable);
 }
 connections.add(connection);
}

代码示例来源:origin: google/guava

@Override
public boolean isEmpty() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.isEmpty();
}

代码示例来源:origin: google/guava

@Override
public boolean add(E element) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.add(element);
}

代码示例来源:origin: square/okhttp

@Override public void write(Buffer source, long byteCount) throws IOException {
 assert (!Thread.holdsLock(Http2Stream.this));
 sendBuffer.write(source, byteCount);
 while (sendBuffer.size() >= EMIT_BUFFER_SIZE) {
  emitFrame(false);
 }
}

代码示例来源:origin: google/guava

@Override
public K getKey() {
 assertTrue(Thread.holdsLock(mutex));
 return super.getKey();
}

代码示例来源:origin: google/guava

@Override
public int hashCode() {
 assertTrue(Thread.holdsLock(mutex));
 return super.hashCode();
}

代码示例来源:origin: google/guava

@Override
public V remove(Object rowKey, Object columnKey) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.remove(rowKey, columnKey);
}

代码示例来源:origin: google/guava

@Override
public E element() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.element();
}

代码示例来源:origin: google/guava

@Override
public boolean containsAll(Collection<?> collection) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.containsAll(collection);
}

代码示例来源:origin: google/guava

@Override
public int size() {
 assertTrue(Thread.holdsLock(mutex));
 return super.size();
}

代码示例来源:origin: google/guava

@Override
public Entry<K, V> ceilingEntry(K key) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().ceilingEntry(key);
}

代码示例来源:origin: google/guava

@Override
public NavigableSet<K> descendingKeySet() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().descendingKeySet();
}

代码示例来源:origin: google/guava

@Override
public Entry<K, V> floorEntry(K key) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().floorEntry(key);
}

代码示例来源:origin: google/guava

@Override
public Entry<K, V> higherEntry(K key) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().higherEntry(key);
}

代码示例来源:origin: google/guava

@Override
public NavigableSet<K> navigableKeySet() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().navigableKeySet();
}

代码示例来源:origin: google/guava

@Override
public boolean equals(@Nullable Object o) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.equals(o);
}

代码示例来源:origin: google/guava

@Override
public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().tailSet(fromElement, inclusive);
}

代码示例来源:origin: google/guava

@Override
public Comparator<? super E> comparator() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate().comparator();
}

代码示例来源:origin: google/guava

@Override
public boolean add(@Nullable E o) {
 assertTrue(Thread.holdsLock(mutex));
 return super.add(o);
}

代码示例来源:origin: google/guava

@Override
public boolean remove(@Nullable Object o) {
 assertTrue(Thread.holdsLock(mutex));
 return super.remove(o);
}

相关文章