Skip to content

Commit e93ad40

Browse files
committed
Merge pull request android-async-http#531 from orientalsensation/AsyncHttpClient
Added ability to get thread pool or set the default one when extending.
2 parents f4cbff2 + 8e6b575 commit e93ad40

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public AsyncHttpClient(SchemeRegistry schemeRegistry) {
217217

218218
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
219219

220-
threadPool = Executors.newCachedThreadPool();
220+
threadPool = getDefaultThreadPool();
221221
requestMap = new WeakHashMap();
222222
clientHeaderMap = new HashMap();
223223

@@ -338,6 +338,25 @@ public void setThreadPool(ThreadPoolExecutor threadPool) {
338338
this.threadPool = threadPool;
339339
}
340340

341+
/**
342+
* Returns the current executor service used. By default,
343+
* Executors.newFixedThreadPool() is used.
344+
*
345+
* @return current executor service used
346+
*/
347+
public ExecutorService getThreadPool() {
348+
return threadPool;
349+
}
350+
351+
/**
352+
* Get the default threading pool to be used for this HTTP client.
353+
*
354+
* @return The default threading pool to be used
355+
*/
356+
protected ExecutorService getDefaultThreadPool() {
357+
return Executors.newCachedThreadPool();
358+
}
359+
341360
/**
342361
* Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
343362
* on underlying HttpClient, effects of this method will be canceled.

0 commit comments

Comments
 (0)