Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Java中的LinkedBlockingQueue创建线程池?_Java - Fatal编程技术网

如何使用Java中的LinkedBlockingQueue创建线程池?

如何使用Java中的LinkedBlockingQueue创建线程池?,java,Java,如何使用Java中的LinkedBlockingQueue创建线程池?我用这个从网上下载文件。我只需要常规模式。ThreadPoolExecutor有一个BlockingQueue参数。不过,还有几个其他参数,您需要选择适合您的问题的参数。ThreadPoolExecutor有一个BlockingQueue参数。不过,还有几个其他参数,您需要选择适合您的问题的参数。以下是一个演示: public static ExecutorService newLinkedBlockingQueueThrea

如何使用Java中的LinkedBlockingQueue创建线程池?我用这个从网上下载文件。我只需要常规模式。

ThreadPoolExecutor
有一个
BlockingQueue
参数。不过,还有几个其他参数,您需要选择适合您的问题的参数。

ThreadPoolExecutor
有一个
BlockingQueue
参数。不过,还有几个其他参数,您需要选择适合您的问题的参数。

以下是一个演示:

public static ExecutorService newLinkedBlockingQueueThreadPool() {
    return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
                                  60L, TimeUnit.SECONDS,
                                  new  LinkedBlockingQueue<Runnable>());
}
公共静态执行器服务newLinkedBlockingQueueThreadPool(){ 返回新的ThreadPoolExecutor(0,Integer.MAX_值, 60升,时间单位。秒, 新建LinkedBlockingQueue()); } 以下是一个演示:

public static ExecutorService newLinkedBlockingQueueThreadPool() {
    return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
                                  60L, TimeUnit.SECONDS,
                                  new  LinkedBlockingQueue<Runnable>());
}
公共静态执行器服务newLinkedBlockingQueueThreadPool(){ 返回新的ThreadPoolExecutor(0,Integer.MAX_值, 60升,时间单位。秒, 新建LinkedBlockingQueue()); }