本文整理匯總了Java中java.util.concurrent.TimeoutException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java TimeoutException.getMessage方法的具體用法?Java TimeoutException.getMessage怎麽用?Java TimeoutException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.TimeoutException
的用法示例。
在下文中一共展示了TimeoutException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
private void init() throws IOException {
ConnectionFactory factory = new ConnectionFactory();
factory.setAutomaticRecoveryEnabled(true);
factory.setHost(this.server);
if (this.port > 0) factory.setPort(this.port);
if (this.username != null && this.username.length() > 0) factory.setUsername(this.username);
if (this.password != null && this.password.length() > 0) factory.setPassword(this.password);
try {
this.connection = factory.newConnection();
//Map<String, Object> map = this.connection.getServerProperties();
if (!this.connection.isOpen()) throw new IOException("no connection");
this.channel = connection.createChannel();
if (!this.channel.isOpen()) throw new IOException("no channel");
this.queues = new ConcurrentHashMap<>();
} catch (TimeoutException e) {
throw new IOException(e.getMessage());
}
}
示例2: waitForStart
import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
@SuppressWarnings({"SleepWhileHoldingLock", "SleepWhileInLoop"})
private boolean waitForStart() throws DatabaseException {
int tries = 0;
while (tries <= 5 && !stopWaiting) {
tries++;
try {
// wait for perform start command first
Thread.sleep(2000);
} catch (InterruptedException ie) {
LOGGER.log(Level.INFO, "Interrupted waiting for server to start", ie);
Thread.currentThread().interrupt();
return false;
}
try {
server.reconnect();
return true;
} catch (DatabaseException dbe) {
errorMessage = dbe.getMessage();
LOGGER.log(Level.INFO, null, dbe);
if (! DatabaseUtils.isCommunicationsException(dbe)) {
throw dbe;
}
} catch (TimeoutException te) {
errorMessage = te.getMessage();
LOGGER.log(Level.INFO, null, te);
}
}
return false;
}
示例3: getDoneFromTimeoutOverload
import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
/**
* Retrieves the result of a {@code Future} known to be done but uses the {@code get(long,
* TimeUnit)} overload in order to test that method.
*/
static <V> V getDoneFromTimeoutOverload(Future<V> future) throws ExecutionException {
checkState(future.isDone(), "Future was expected to be done: %s", future);
try {
return getUninterruptibly(future, 0, SECONDS);
} catch (TimeoutException e) {
AssertionFailedError error = new AssertionFailedError(e.getMessage());
error.initCause(e);
throw error;
}
}