Skip to content

Commit 405e21a

Browse files
natario1rogerhu
authored andcommitted
Jump off the network executor when needed (#655)
1 parent 4e4ffad commit 405e21a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ private static ThreadPoolExecutor newThreadPoolExecutor(int corePoolSize, int ma
6262
return executor;
6363
}
6464

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-
*/
7065
protected static final ExecutorService NETWORK_EXECUTOR = newThreadPoolExecutor(
7166
CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS,
7267
new LinkedBlockingQueue<Runnable>(MAX_QUEUE_SIZE), sThreadFactory);
@@ -151,8 +146,9 @@ public Task<Response> then(Task<Response> task) throws Exception {
151146
}
152147
}
153148
return task;
149+
// Jump off the network executor so this task continuations won't steal network threads
154150
}
155-
}, NETWORK_EXECUTOR);
151+
}, Task.BACKGROUND_EXECUTOR);
156152
}
157153

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

0 commit comments

Comments
 (0)