Use dedicate operation executor

pull/212/head
M66B 2 years ago
parent fdaa270b80
commit a7c79ffc0c

@ -260,9 +260,6 @@ public class Helper {
private static ExecutorService sMediaExecutor = null;
private static ExecutorService sDownloadExecutor = null;
private static int sOperationIndex = 0;
private static final ExecutorService[] sOperationExecutor = new ExecutorService[OPERATION_WORKERS];
static ExecutorService getSerialExecutor() {
if (sSerialExecutor == null)
sSerialExecutor = getBackgroundExecutor(1, "serial");
@ -293,16 +290,6 @@ public class Helper {
return sDownloadExecutor;
}
static ExecutorService getOperationExecutor() {
synchronized (sOperationExecutor) {
if (sOperationExecutor[sOperationIndex] == null)
sOperationExecutor[sOperationIndex] = getBackgroundExecutor(1, "operation");
ExecutorService result = sOperationExecutor[sOperationIndex];
sOperationIndex = (sOperationIndex + 1) % sOperationExecutor.length;
return result;
}
}
static ExecutorService getBackgroundExecutor(int threads, final String name) {
ThreadFactory factory = new ThreadFactory() {
private final AtomicInteger threadId = new AtomicInteger();

@ -1550,7 +1550,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i(account.name + " run thread=" + currentThread);
final ObjectHolder<TwoStateOwner> cowner = new ObjectHolder<>();
final ExecutorService executor = Helper.getOperationExecutor();
final ExecutorService executor = Helper.getBackgroundExecutor(1, "operation." + account.id);
// Debug
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

Loading…
Cancel
Save