当前位置: 首页>>代码示例>>Java>>正文


Java UncaughtExceptionHandlers类代码示例

本文整理汇总了Java中com.google.common.util.concurrent.UncaughtExceptionHandlers的典型用法代码示例。如果您正苦于以下问题:Java UncaughtExceptionHandlers类的具体用法?Java UncaughtExceptionHandlers怎么用?Java UncaughtExceptionHandlers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UncaughtExceptionHandlers类属于com.google.common.util.concurrent包,在下文中一共展示了UncaughtExceptionHandlers类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExecutor

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
ExecutorService getExecutor(int asyncThreads) {
  // TODO(carl-mastrangelo): This should not be necessary.  I don't know where this should be
  // put.  Move it somewhere else, or remove it if no longer necessary.
  // See: https://github.com/grpc/grpc-java/issues/2119
  return new ForkJoinPool(asyncThreads,
      new ForkJoinWorkerThreadFactory() {
        final AtomicInteger num = new AtomicInteger();
        @Override
        public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
          ForkJoinWorkerThread thread = defaultForkJoinWorkerThreadFactory.newThread(pool);
          thread.setDaemon(true);
          thread.setName("server-worker-" + "-" + num.getAndIncrement());
          return thread;
        }
      }, UncaughtExceptionHandlers.systemExit(), true /* async */);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:17,代码来源:LoadServer.java

示例2: getExecutor

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
private static synchronized ExecutorService getExecutor() {
  if (clientExecutor == null) {
    clientExecutor = new ForkJoinPool(
        Runtime.getRuntime().availableProcessors(),
        new ForkJoinWorkerThreadFactory() {
          final AtomicInteger num = new AtomicInteger();
          @Override
          public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
            ForkJoinWorkerThread thread = defaultForkJoinWorkerThreadFactory.newThread(pool);
            thread.setDaemon(true);
            thread.setName("grpc-client-app-" + "-" + num.getAndIncrement());
            return thread;
          }
        }, UncaughtExceptionHandlers.systemExit(), true /* async */);
  }
  return clientExecutor;
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:18,代码来源:Utils.java

示例3: run

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
@Override
public void run() {
    Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());
    Application application = this.application.get();
    if (runtime.getConfiguration().getArguments().getProgramName().isEmpty()) {
        runtime.getConfiguration().getArguments().setProgramName(application.getClass().getName());
    }
    exitIfHelpSet(runtime.getConfiguration().getArguments());
    logger.info("{}", runtime.getConfiguration().getConfig());
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            runtime.shutdown();
        }
    });
    application.run();
    logger.info("Exiting");
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:19,代码来源:DefaultMain.java

示例4: createSingleThreadExecutor

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
/**
 * Separated out for easy overriding in tests.
 */
@VisibleForTesting
protected ExecutorService createSingleThreadExecutor() {
  return Executors.newSingleThreadExecutor(
      new ThreadFactoryBuilder()
        .setDaemon(true)
        .setNameFormat("Logger channel (from single-thread executor) to " +
            addr)
        .setUncaughtExceptionHandler(
            UncaughtExceptionHandlers.systemExit())
        .build());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:IPCLoggerChannel.java

示例5: createParallelExecutor

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
/**
 * Separated out for easy overriding in tests.
 */
@VisibleForTesting
protected ExecutorService createParallelExecutor() {
  return Executors.newCachedThreadPool(
      new ThreadFactoryBuilder()
          .setDaemon(true)
          .setNameFormat("Logger channel (from parallel executor) to " + addr)
          .setUncaughtExceptionHandler(
              UncaughtExceptionHandlers.systemExit())
          .build());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:IPCLoggerChannel.java

示例6: createExecutor

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
/**
 * Separated out for easy overriding in tests.
 */
@VisibleForTesting
protected ExecutorService createExecutor() {
  return Executors.newSingleThreadExecutor(
      new ThreadFactoryBuilder()
        .setDaemon(true)
        .setNameFormat("Logger channel to " + addr)
        .setUncaughtExceptionHandler(
            UncaughtExceptionHandlers.systemExit())
        .build());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:14,代码来源:IPCLoggerChannel.java

示例7: RealCommandContext

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
RealCommandContext() {
  ThreadFactory threadFactory =
      new ThreadFactoryBuilder()
          .setNameFormat("gletscher-pool-%d")
          .setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit())
          .build();
  executor =
      MoreExecutors.listeningDecorator(
          new ThreadPoolExecutor(
              4, 32, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(1024), threadFactory));
}
 
开发者ID:pmoor,项目名称:gletscher,代码行数:12,代码来源:GletscherMain.java

示例8: main

import com.google.common.util.concurrent.UncaughtExceptionHandlers; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());

	maybeEnableDemo();

	Server server = new Server(PORT);

	ServletContextHandler contextHandler = new ServletContextHandler(server, "/");
	addDefaultServlet(contextHandler);

	addJerseyServlet(contextHandler);
	addCorHeadersFilter(contextHandler);

	server.start();
	server.join();
}
 
开发者ID:greensopinion,项目名称:greenbeans,代码行数:17,代码来源:WebServerRunner.java


注:本文中的com.google.common.util.concurrent.UncaughtExceptionHandlers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。