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


Java AsynchronousChannelGroup.shutdown方法代碼示例

本文整理匯總了Java中java.nio.channels.AsynchronousChannelGroup.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java AsynchronousChannelGroup.shutdown方法的具體用法?Java AsynchronousChannelGroup.shutdown怎麽用?Java AsynchronousChannelGroup.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.channels.AsynchronousChannelGroup的用法示例。


在下文中一共展示了AsynchronousChannelGroup.shutdown方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.nio.channels.AsynchronousChannelGroup; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // create channel groups
    ThreadFactory factory = new PrivilegedThreadFactory();
    AsynchronousChannelGroup group1 = AsynchronousChannelGroup
        .withFixedThreadPool(5, factory);
    AsynchronousChannelGroup group2 = AsynchronousChannelGroup
        .withCachedThreadPool(Executors.newCachedThreadPool(factory), 0);
    AsynchronousChannelGroup group3 = AsynchronousChannelGroup
        .withThreadPool(Executors.newFixedThreadPool(10, factory));

    try {
        // execute simple tasks
        testSimpleTask(group1);
        testSimpleTask(group2);
        testSimpleTask(group3);

        // install security manager and test again
        System.setSecurityManager( new SecurityManager() );
        testSimpleTask(group1);
        testSimpleTask(group2);
        testSimpleTask(group3);

        // attempt to execute tasks that run with only frames from boot
        // class loader on the stack.
        testAttackingTask(group1);
        testAttackingTask(group2);
        testAttackingTask(group3);
    } finally {
        group1.shutdown();
        group2.shutdown();
        group3.shutdown();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:AsExecutor.java

示例2: main

import java.nio.channels.AsynchronousChannelGroup; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // create channel groups
    ThreadFactory factory = new PrivilegedThreadFactory();
    AsynchronousChannelGroup group1 = AsynchronousChannelGroup
        .withFixedThreadPool(5, factory);
    AsynchronousChannelGroup group2 = AsynchronousChannelGroup
        .withCachedThreadPool(Executors.newCachedThreadPool(factory), 0);

    try {
        // execute simple tasks
        testSimpleTask(group1);
        testSimpleTask(group2);

        // install security manager and test again
        System.setSecurityManager( new SecurityManager() );
        testSimpleTask(group1);
        testSimpleTask(group2);

        // attempt to execute tasks that run with only frames from boot
        // class loader on the stack.
        testAttackingTask(group1);
        testAttackingTask(group2);
    } finally {
        group1.shutdown();
        group2.shutdown();
    }
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:28,代碼來源:AsExecutor.java


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