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


Java ExecutorService.isShutdown方法代码示例

本文整理汇总了Java中java.util.concurrent.ExecutorService.isShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutorService.isShutdown方法的具体用法?Java ExecutorService.isShutdown怎么用?Java ExecutorService.isShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ExecutorService的用法示例。


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

示例1: shutdownAndAwaitTermination

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
/**
 * Shutdown cordova thread pool. This assumes we are in control of all tasks running
 * in the thread pool.
 * Additional info: http://developer.android.com/reference/java/util/concurrent/ExecutorService.html
 * @param pool Cordova application's thread pool
 */
private void shutdownAndAwaitTermination(ExecutorService pool) {
    Log.d(TAG,"Attempting to shutdown cordova threadpool");
    if(!pool.isShutdown()){
        try {
            // Disable new tasks from being submitted
            pool.shutdown();
            // Wait a while for existing tasks to terminate
            if (!pool.awaitTermination(5, TimeUnit.SECONDS)) {
                pool.shutdownNow(); // Cancel currently executing tasks
                // Wait a while for tasks to respond to being cancelled
                if (!pool.awaitTermination(30, TimeUnit.SECONDS)) {
                    System.err.println("Cordova thread pool did not terminate.");
                }
            }
        }
        catch (InterruptedException ie) {
            // Preserve interrupt status
            Thread.currentThread().interrupt();
        }
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:28,代码来源:AdvancedGeolocation.java

示例2: shutdown

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
public void shutdown() {
    ExecutorService executor = null;

    synchronized (this) {
        // swap
        if (service != null) {
            executor = service;
            service = null;
        }
    }

    if (executor != null) {
        // shutdown
        if (!executor.isShutdown()) {
            executor.shutdown();
        }

        // recycle
        executor = null;
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:22,代码来源:NimTaskExecutor.java

示例3: shutdown

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
public void shutdown() {
	ExecutorService executor = null;

	synchronized (this) {
		// swap
		if (service != null) {
			executor = service;
			service = null;
		}
	}

	if (executor != null) {
		// shutdown
		if (!executor.isShutdown()) {
			executor.shutdown();
		}

		// recycle
		executor = null;
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:22,代码来源:TaskExecutor.java

示例4: sendNotificationWave

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
/**
 * That method starts a set of threads, each thread sends a given number of
 * notifications.
 * The number of threads can be set via the attribute numOfNotificationSenders.
 * The number of notification sent by each thread can be set via
 * the attribute numOfNotificationSenderLoops.
 * Depending on the parameter customNotification we send either custom
 * notification(s) or MBeanServer registration and unregistration notification(s).
 * When customNotification=true the total number of notification(s) sent is
 * (numOfNotificationSenders * numOfNotificationSenderLoops). They are
 * sequentially of type NOTIF_TYPE_0 then NOTIF_TYPE_1 and so on.
 *
 * When customNotification=false the total number of notification(s) sent is
 * (numOfNotificationSenders * numOfNotificationSenderLoops) registration
 * notification(s)
 * +
 * (numOfNotificationSenders * numOfNotificationSenderLoops) unregistration
 * notification(s)
 *
 * @throws java.lang.Exception
 */
public void sendNotificationWave(boolean customNotification) throws
        Exception {
    // Build the set of notification sender.
    Collection<Callable<Integer>> tasks =
            new HashSet<Callable<Integer>>(numOfNotificationSenders);

    for (int i = 1; i <= numOfNotificationSenders; i++) {
        tasks.add(new NotifSender(numOfNotificationSenderLoops,
                customNotification, i));
    }

    // Start all notification sender in parallel.
    ExecutorService execServ = null;
    try {
        execServ = Executors.newFixedThreadPool(numOfNotificationSenders);
        List<Future<Integer>> taskHandlers = execServ.invokeAll(tasks);
        checkNotifSenderThreadStatus(taskHandlers);
    } finally {
        if (!execServ.isShutdown()) {
            execServ.shutdown();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:Basic.java

示例5: validateTestTree

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
@Override
public boolean validateTestTree(final String sessionId) {
	final TestTree copy = getTree(sessionId);
	if (null == copy) {
		throw new IllegalStateException("Test tree does not exist for session. Session ID: '" + sessionId + "'.");
	}
	synchronized (this) {
		final ExecutorService executorService = getExecutorService(sessionId);
		if (debugEnabled) {
			LOGGER.debug("Validating test tree for session: '" + sessionId + "'.");
		}
		if (!executorService.isShutdown()) {
			if (debugEnabled) {
				LOGGER.debug("Test tree is incomplete. Waiting for executors to finish the tree state update...");
			}
			try {
				executorService.shutdown();
				executorService.awaitTermination(timeout, MILLISECONDS);
			} catch (final InterruptedException e) {
				throw new RuntimeException(e);
			}
			if (debugEnabled) {
				LOGGER.debug("Test tree is in complete state.");
			}
		}
		return validate(getTree(sessionId));
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:TestTreeRegistryImpl.java

示例6: getExecutorService

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
private ExecutorService getExecutorService() {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) { 
        cexecutor = SHARED_EXECUTOR;
    }
    return cexecutor;
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:8,代码来源:AllChannelHandler.java

示例7: received

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
public void received(Channel channel, Object message) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) {
        cexecutor = SHARED_EXECUTOR;
    }
    try {
        cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
    } catch (Throwable t) {
        throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:ConnectionOrderedChannelHandler.java

示例8: caught

import java.util.concurrent.ExecutorService; //导入方法依赖的package包/类
public void caught(Channel channel, Throwable exception) throws RemotingException {
    ExecutorService cexecutor = executor;
    if (cexecutor == null || cexecutor.isShutdown()) { 
        cexecutor = SHARED_EXECUTOR;
    } 
    try{
        cexecutor.execute(new ChannelEventRunnable(channel, handler ,ChannelState.CAUGHT, exception));
    }catch (Throwable t) {
        throw new ExecutionException("caught event", channel, getClass()+" error when process caught event ." , t);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:ConnectionOrderedChannelHandler.java


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