本文整理匯總了Java中java.nio.channels.CancelledKeyException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java CancelledKeyException.printStackTrace方法的具體用法?Java CancelledKeyException.printStackTrace怎麽用?Java CancelledKeyException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.channels.CancelledKeyException
的用法示例。
在下文中一共展示了CancelledKeyException.printStackTrace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: select
import java.nio.channels.CancelledKeyException; //導入方法依賴的package包/類
static int select(Selector selector) throws IOException {
try {
return selector.select(SELECT_TIMEOUT);
} catch (CancelledKeyException e) {
// if (logger.isDebugEnabled()) {
// logger.debug(
// CancelledKeyException.class.getSimpleName() +
// " raised by a Selector - JDK bug?", e);
// }
e.printStackTrace();
// Harmless exception - log anyway
}
return -1;
}
示例2: invokeCallbacks
import java.nio.channels.CancelledKeyException; //導入方法依賴的package包/類
/** Set the selected interest set on the port and run it. */
protected void invokeCallbacks() {
final Set<SelectionKey> selectedKeys = m_selector.selectedKeys();
ArrayList<Runnable> generatedTasks = null;
for(SelectionKey key : selectedKeys) {
final VoltPort port = (VoltPort) key.attachment();
if (port == null) {
continue;
}
try {
port.lockForHandlingWork();
key.interestOps(0);
final Runnable runner = getPortCallRunnable(port);
if (m_useExecutorService) {
if (generatedTasks == null) generatedTasks = new ArrayList<Runnable>();
generatedTasks.add(runner);
} else {
runner.run();
}
}
catch (CancelledKeyException e) {
e.printStackTrace();
// no need to do anything here until
// shutdown makes more sense
}
}
if (generatedTasks != null && !generatedTasks.isEmpty()) {
synchronized (m_tasks) {
m_tasks.addAll(generatedTasks);
if (m_tasks.size() > 1) {
m_tasks.notifyAll();
} else {
m_tasks.notify();
}
}
}
selectedKeys.clear();
}