本文整理匯總了Java中java.util.concurrent.BlockingDeque.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockingDeque.isEmpty方法的具體用法?Java BlockingDeque.isEmpty怎麽用?Java BlockingDeque.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.BlockingDeque
的用法示例。
在下文中一共展示了BlockingDeque.isEmpty方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GwtcJobMonitorImpl
import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
public GwtcJobMonitorImpl(BlockingDeque<String> caller, BlockingDeque<String> compiler) {
// We were instantiated directly, so assume we are running in a foreign classloader,
// and that our parameters are a pair of LinkedBlockingDeque's that we can use to communicate with.
readAsCaller = compiler::take;
readAsCompiler = caller::take;
writeAsCaller = caller::put;
writeAsCompiler = compiler::put;
hasCallerOutput = ()->!caller.isEmpty();
hasCompilerOutput = ()->!compiler.isEmpty();
}
示例2: getAllConfidence
import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
public void getAllConfidence(Set<String> pokemonSet, int size) throws IOException {
final Map<String, Double> confidences = new HashMap<>();
//I'm so lazy right now.
Set<Set<String>> pokemonSets = new HashSet<>();
for (String p1 : pokemonSet) {
if (size == 1) {
pokemonSets.add(Sets.newHashSet(p1));
} else {
for (String p2 : pokemonSet) {
if (p1.equals(p2)) continue;
if (size == 2) {
pokemonSets.add(Sets.newHashSet(p1, p2));
} else {
for (String p3 : pokemonSet) {
if (p1.equals(p3) || p2.equals(p3)) continue;
pokemonSets.add(Sets.newHashSet(p1,p2,p3));
}
}
}
}
}
final BlockingDeque<Set<String>> pokemon = new LinkedBlockingDeque<>(pokemonSets);
Runnable task = new Runnable() {
@Override
public void run() {
while (!pokemon.isEmpty()) {
Set<String> pokemonBeingAnalyzed = pokemon.poll();
Double confidence;
try {
confidence = new PokemonWinAnalysis(pokemonBeingAnalyzed).getConfidence();
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(setToString(pokemonBeingAnalyzed) + ", " + confidence);
}
}
};
new Thread(task).start();
new Thread(task).start();
new Thread(task).start();
}
示例3: assertExpectedUpdatesWritten
import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
private void assertExpectedUpdatesWritten() throws InterruptedException {
final AtomicReference<String> failureText = new AtomicReference<String>();
cougarOutput.addListener(new ExpectingOutput.ExpectingOutputListener() {
@Override
public void failure(String s) {
failureText.set(s);
}
@Override
public void complete() {
}
});
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Starting wait for expected updates");
}
cougarOutput.start();
BlockingDeque queue = subject.getHeapsWaitingForUpdate();
while (!queue.isEmpty()) {
Thread.sleep(10);
}
// queue empty, now check the heap stats
boolean allDone = false;
while (!allDone) {
allDone = true;
for (PooledServerConnectedObjectManager.HeapState heapState : subject.getHeapStates().values()) {
Lock lock = heapState.getUpdateLock();
lock.lock();
try {
if (!heapState.getQueuedChanges().isEmpty()) {
allDone = false;
break;
}
}
finally {
lock.unlock();
}
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("CougarObjectOutput.writeObject():");
for (Object o : new ArrayList<Object>(cougarOutput.getAllValues())) {
LOGGER.debug(String.valueOf(o));
}
}
if (failureText.get() != null) {
fail(failureText.get());
}
// add in checks for the terminate subs
assertEquals(cougarOutput.getExpectedSubTerminations(), cougarOutput.getSubTerminations());
}