当使用 ThreadPoolExecutor 时,我可以使用 AsyncTask 作为队列中的 Runnable 吗?或者这是否违背了目的?
//A holder for various tasks
private final LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(5);
//Thread Pool Executor
private final ThreadPoolExecutor tpe = new ThreadPoolExecutor(3, 3, 10, TimeUnit.SECONDS, queue);
最佳答案
AsyncTask 不是 Runnable,因此您不能真正使用它。
关于java - 使用 ThreadPoolExecutor 和 AsyncTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2251806/