2010-02-12 83 views
3

使用ThreadPoolExecutor時,我可以使用AsyncTask作爲隊列中的Runnable嗎?或者這是否打破了目的?使用ThreadPoolExecutor和AsyncTask

//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); 

回答

6

AsyncTask不是一個Runnable,所以你不能真正使用它。