本文整理匯總了Java中java.util.concurrent.ExecutionException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ExecutionException.printStackTrace方法的具體用法?Java ExecutionException.printStackTrace怎麽用?Java ExecutionException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.ExecutionException
的用法示例。
在下文中一共展示了ExecutionException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
long startTime = System.currentTimeMillis();
int count = 0;
for (int i = 1; i < 10; i++) {
count = count + i;
Thread.sleep(1000);
}
System.out.println(count);
long endTime = System.currentTimeMillis(); // 獲取結束時間
System.out.println("程序運行時間: " + (startTime - endTime) + "ms");
long startTime1 = System.currentTimeMillis();
CountTask countTask = new CountTask(1, 10);
ForkJoinPool forkJoinPool = new ForkJoinPool();
Future<Integer> futureTask = forkJoinPool.submit(countTask);
try {
System.out.println(futureTask.get());
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long endTime1 = System.currentTimeMillis(); // 獲取結束時間
System.out.println("程序運行時間: " + (startTime1 - endTime1) + "ms");
}
示例2: exists
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Override
public boolean exists(String key) {
try {
cache.get(key, new Callable<Object>() {
@Override
public Object call() throws Exception {
return null;
}
});
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
示例3: done
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Override
protected void done() {
super.done();
if (isCancelled()) {
return;
}
try {
get();
} catch (ExecutionException ex) {
ex.printStackTrace();
// Logger log = owner == null ? GlowServer.logger : owner.getLogger();
// log.log(Level.SEVERE, "Error while executing " + this, ex.getCause());
} catch (InterruptedException e) {
// Task is already done, see the fact that we're in done() method
}
}
示例4: runTest
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
private void runTest(JasminBuilder builder, String main, String expected) throws Exception {
if (runsOnJVM) {
String javaResult = runOnJava(builder, main);
assertEquals(expected, javaResult);
}
String artResult = null;
try {
artResult = runOnArt(builder, main);
fail();
} catch (ExecutionException t) {
if (!(t.getCause() instanceof CompilationError)) {
t.printStackTrace(System.out);
fail("Invalid dex field names should be compilation errors.");
}
}
assertNull("Invalid dex field names should be rejected.", artResult);
}
示例5: createReEncryptionKey
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Override
protected ReEncryptionKeyInstance createReEncryptionKey(String sourceEncryptionKeyName, String destinationEncryptionKeyName) {
try {
return reEncryptionKeyCache.get(
new ReEncryptionKeyCacheKey(sourceEncryptionKeyName, destinationEncryptionKeyName));
} catch (ExecutionException e)
{
e.printStackTrace(System.err);
}
return null;
}
示例6: getFiltered
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
public static String getFiltered(String s) {
String filtered;
try {
filtered = filteredCache.get(s);
return filtered;
} catch (ExecutionException e) {
e.printStackTrace();
return s;
}
}
示例7: getTicket
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
public String getTicket() {
try {
return ticketCache.get(appIdSecret);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
示例8: getAccessToken
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
public String getAccessToken(AppIdSecret instance) {
if(instance == null){
instance = appIdSecret;
}
try {
return accessTokenCache.get(instance);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
示例9: evaluate
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Override
public Result evaluate() throws Throwable
{
// Obtain ThreadPoolExecutor (new instance on each test method for now)
ExecutorService executor = getExecutor(concurrency, totalRounds);
CompletionService<SingleResult> completed = new ExecutorCompletionService<SingleResult>(
executor);
for (int i = 0; i < totalRounds; i++)
{
completed.submit(new EvaluatorCallable(i));
}
// Allow all the evaluators to proceed to the warmup phase.
latch.countDown();
warmupTime = clock.time();
benchmarkTime = 0;
try
{
for (int i = 0; i < totalRounds; i++)
{
results.add(completed.take().get());
}
benchmarkTime = clock.time() - benchmarkTime;
return computeResult();
}
catch (ExecutionException e)
{
// Unwrap the Throwable thrown by the tested method.
e.printStackTrace();
throw e.getCause().getCause();
}
finally
{
// Assure proper executor cleanup either on test failure or an successful completion
cleanupExecutor(executor);
}
}
示例10: getConfig
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
/**
* 獲取配置文件信息
* @param mode 指定測試環境
* @return
*/
public static Map<String, String> getConfig(TestEnv mode) {
Map<String, String> result = null;
try {
result = configsCache.get(mode, () -> init(mode));
} catch (ExecutionException e) {
e.printStackTrace();
}
return result;
}
示例11: waitForCompletion
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
/**
* Waits for all threads to complete computation.
*
* @param futures
*/
public static void waitForCompletion(Future<?>[] futures) {
int size = futures.length;
try {
for (int j = 0; j < size; j++) {
futures[j].get();
}
} catch (ExecutionException ex) {
ex.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
示例12: shouldNotifyTrueWithAttribSendNotificationOnlyIfStateChangeFalse
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Test
public void shouldNotifyTrueWithAttribSendNotificationOnlyIfStateChangeFalse() throws OpampException {
CiChangeStateEvent ciEvent = new CiChangeStateEvent();
ciEvent.setCiId(12345);
ciEvent.setNewState(CiOpsState.notify.getName());
ciEvent.setOldState(CiOpsState.notify.getName());
OpsBaseEvent obe = new OpsBaseEvent();
obe.setCiId(12345);
obe.setManifestId(6789);
obe.setBucket("mockBucket");
obe.setSource("p1-compute-load");
obe.setStatus(Status.NEW);
Gson gson = new Gson();
ciEvent.setPayLoad(gson.toJson(obe));
WatchedByAttributeCache cacheWithNotifyOnlyOnStateChangeTrue = mock(WatchedByAttributeCache.class);
LoadingCache<String, String> cache = mock(LoadingCache.class);
eventUtil.setCache(cacheWithNotifyOnlyOnStateChangeTrue);
try {
when(cache.get(eventUtil.getKey(obe))).thenReturn(String.valueOf("false"));
when(cacheWithNotifyOnlyOnStateChangeTrue.instance()).thenReturn(cache);
} catch (ExecutionException e) {
e.printStackTrace();
}
boolean actualValue = eventUtil.shouldNotify(ciEvent, obe);
Assert.assertEquals(actualValue, true);
}
示例13: shouldNotifyFalseWithOldStatusCIAndAttribSendNotificationOnlyIfStateChangeTrue
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Test
public void shouldNotifyFalseWithOldStatusCIAndAttribSendNotificationOnlyIfStateChangeTrue() throws OpampException {
CiChangeStateEvent ciEvent = new CiChangeStateEvent();
ciEvent.setCiId(12345);
ciEvent.setNewState(CiOpsState.notify.getName());
ciEvent.setOldState(CiOpsState.notify.getName());
OpsBaseEvent obe = new OpsBaseEvent();
obe.setCiId(12345);
obe.setManifestId(6789);
obe.setBucket("mockBucket");
obe.setSource("p1-compute-load");
obe.setStatus(Status.EXISTING);
Gson gson = new Gson();
ciEvent.setPayLoad(gson.toJson(obe));
WatchedByAttributeCache cacheWithNotifyOnlyOnStateChangeTrue = mock(WatchedByAttributeCache.class);
LoadingCache<String, String> cache = mock(LoadingCache.class);
eventUtil.setCache(cacheWithNotifyOnlyOnStateChangeTrue);
try {
when(cache.get(eventUtil.getKey(obe))).thenReturn(String.valueOf("true"));
when(cacheWithNotifyOnlyOnStateChangeTrue.instance()).thenReturn(cache);
} catch (ExecutionException e) {
e.printStackTrace();
}
boolean actualValue = eventUtil.shouldNotify(ciEvent, obe);
Assert.assertEquals(actualValue, false);
}
示例14: shouldNotifyFalseAndExceptionInGettingAttribValue
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Test
public void shouldNotifyFalseAndExceptionInGettingAttribValue() throws OpampException {
CiChangeStateEvent ciEvent = new CiChangeStateEvent();
ciEvent.setCiId(12345);
ciEvent.setNewState(CiOpsState.notify.getName());
ciEvent.setOldState(CiOpsState.notify.getName());
OpsBaseEvent obe = new OpsBaseEvent();
obe.setCiId(12345);
obe.setManifestId(6789);
obe.setBucket("mockBucket");
obe.setSource("p1-compute-load");
obe.setStatus(Status.EXISTING);
Gson gson = new Gson();
ciEvent.setPayLoad(gson.toJson(obe));
WatchedByAttributeCache cacheWithNotifyOnlyOnStateChangeTrue = mock(WatchedByAttributeCache.class);
LoadingCache<String, String> cache = mock(LoadingCache.class);
eventUtil.setCache(cacheWithNotifyOnlyOnStateChangeTrue);
try {
when(cache.get(eventUtil.getKey(obe))).thenThrow(new ExecutionException(null));
when(cacheWithNotifyOnlyOnStateChangeTrue.instance()).thenReturn(cache);
} catch (ExecutionException e) {
e.printStackTrace();
}
boolean actualValue = eventUtil.shouldNotify(ciEvent, obe);
Assert.assertEquals(actualValue, false);
}
示例15: shouldNotifyFalseWithNewStateNotifyAndOldStateHealthyAndAttribSendNotificationOnlyIfStateChangeTrue
import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
@Test
public void shouldNotifyFalseWithNewStateNotifyAndOldStateHealthyAndAttribSendNotificationOnlyIfStateChangeTrue() throws OpampException {
CiChangeStateEvent ciEvent = new CiChangeStateEvent();
ciEvent.setCiId(12345);
ciEvent.setNewState(CiOpsState.notify.getName());
ciEvent.setOldState("healthy");
OpsBaseEvent obe = new OpsBaseEvent();
obe.setCiId(12345);
obe.setManifestId(6789);
obe.setBucket("mockBucket");
obe.setSource("p1-compute-load");
obe.setStatus(Status.NEW);
Gson gson = new Gson();
ciEvent.setPayLoad(gson.toJson(obe));
WatchedByAttributeCache cacheWithNotifyOnlyOnStateChangeTrue = mock(WatchedByAttributeCache.class);
LoadingCache<String, String> cache = mock(LoadingCache.class);
eventUtil.setCache(cacheWithNotifyOnlyOnStateChangeTrue);
try {
when(cache.get(eventUtil.getKey(obe))).thenReturn(String.valueOf("true"));
when(cacheWithNotifyOnlyOnStateChangeTrue.instance()).thenReturn(cache);
} catch (ExecutionException e) {
e.printStackTrace();
}
boolean actualValue = eventUtil.shouldNotify(ciEvent, obe);
Assert.assertEquals(actualValue, true);
}