當前位置: 首頁>>代碼示例>>Java>>正文


Java ExecutionException.printStackTrace方法代碼示例

本文整理匯總了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");

}
 
開發者ID:leon66666,項目名稱:JavaCommon,代碼行數:26,代碼來源:ForkJoinTaskDemo.java

示例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;
}
 
開發者ID:zh-cn-trio,項目名稱:trioAop,代碼行數:17,代碼來源:GuavaStringOperation.java

示例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
    }
}
 
開發者ID:CloudLandGame,項目名稱:CloudLand-Server,代碼行數:18,代碼來源:GlowTask.java

示例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);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:18,代碼來源:InvalidFieldNames.java

示例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;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:12,代碼來源:CachingReEncryptionKeyProvider.java

示例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;
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:11,代碼來源:ChatFilter.java

示例7: getTicket

import java.util.concurrent.ExecutionException; //導入方法依賴的package包/類
public String getTicket() {
	try {
		return ticketCache.get(appIdSecret);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:tojaoomy,項目名稱:private-WeChat,代碼行數:9,代碼來源:TicketJob.java

示例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;
}
 
開發者ID:tojaoomy,項目名稱:private-WeChat,代碼行數:12,代碼來源:AccessTokenJob.java

示例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);
    }
}
 
開發者ID:adnanmitf09,項目名稱:Rubus,代碼行數:41,代碼來源:BenchmarkStatement.java

示例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;
}
 
開發者ID:DreamYa0,項目名稱:zeratul,代碼行數:15,代碼來源:SqlConfig.java

示例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();
    }
}
 
開發者ID:gstraube,項目名稱:cythara,代碼行數:18,代碼來源:ConcurrencyUtils.java

示例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);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:EventUtilTest.java

示例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);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:EventUtilTest.java

示例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);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:EventUtilTest.java

示例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);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:EventUtilTest.java


注:本文中的java.util.concurrent.ExecutionException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。