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