Skip to content

Commit 44eca49

Browse files
natario1rogerhu
authored andcommitted
Fix executor for network requests (#648)
1 parent 803d260 commit 44eca49

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Parse/src/main/java/com/parse/ParseRequest.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ private static ThreadPoolExecutor newThreadPoolExecutor(int corePoolSize, int ma
6262
return executor;
6363
}
6464

65-
/* package */ static final ExecutorService NETWORK_EXECUTOR = newThreadPoolExecutor(
65+
/**
66+
* This executor should be used for any network operation, in all subclasses.
67+
* Chaining network operations with tasks consumed by Task.BACKGROUND_EXECUTOR , which is smaller,
68+
* will cause performance bottlenecks and possibly lock the whole SDK.
69+
*/
70+
protected static final ExecutorService NETWORK_EXECUTOR = newThreadPoolExecutor(
6671
CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS,
6772
new LinkedBlockingQueue<Runnable>(MAX_QUEUE_SIZE), sThreadFactory);
6873

@@ -147,7 +152,7 @@ public Task<Response> then(Task<Response> task) throws Exception {
147152
}
148153
return task;
149154
}
150-
}, Task.BACKGROUND_EXECUTOR);
155+
}, NETWORK_EXECUTOR);
151156
}
152157

153158
protected abstract Task<Response> onResponseAsync(ParseHttpResponse response,

0 commit comments

Comments
 (0)