赞
踩
目录
本文摘自java并发编程的艺术(本文摘出来用于本人学习)
Executor框架主要由3大部分组成如下。
public static ExecutorService newFixedThreadPool(int nThreads)public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactorythreadFacto
public static ExecutorService newSingleThreadExecutor()public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)
public static ExecutorService newCachedThreadPool()public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize,threadFactory)
public static ScheduledExecutorService newSingleThreadScheduledExecutor()public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory threadFactory)
<T> Future<T> submit(Callable<T> task)<T> Future<T> submit(Runnable task, T result)Future<> submit(Runnable task)
public static Callable<Object> callable(Runnable task) // 假 设 返回 对 象 Callable1
下面是Executors提供的,把一个Runnable和一个待返回的结果包装成一个Callable的API。
public static <T> Callable<T> callable(Runnable task, T result) // 假 设 返回 对象Callable2
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。