当前位置: 首页>>代码示例>>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;未经允许,请勿转载。