當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。