mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-04 16:16:33 +02:00
Replaced threads by executor
This commit is contained in:
@@ -62,8 +62,6 @@ import javax.mail.Session;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||
|
||||
public class ServiceSend extends ServiceBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private TupleUnsent lastUnsent = null;
|
||||
private Network lastActive = null;
|
||||
@@ -706,10 +704,12 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
||||
}
|
||||
|
||||
static void boot(final Context context) {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
EntityLog.log(context, "Boot send service");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
EntityFolder outbox = db.folder().getOutbox();
|
||||
@@ -726,9 +726,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
}, "send:boot");
|
||||
thread.setPriority(THREAD_PRIORITY_BACKGROUND);
|
||||
thread.start();
|
||||
});
|
||||
}
|
||||
|
||||
static void start(Context context) {
|
||||
|
||||
@@ -111,6 +111,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
private MutableLiveData<List<TupleAccountState>> liveAccountState = new MutableLiveData<>();
|
||||
private MediatorState liveAccountNetworkState = new MediatorState();
|
||||
|
||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "sync");
|
||||
|
||||
private static final long PURGE_DELAY = 30 * 1000L; // milliseconds
|
||||
private static final long QUIT_DELAY = 5 * 1000L; // milliseconds
|
||||
private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds
|
||||
@@ -2138,10 +2140,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
}
|
||||
|
||||
static void boot(final Context context) {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
EntityLog.log(context, "Boot sync service");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
@@ -2187,9 +2191,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
}, "synchronize:boot");
|
||||
thread.setPriority(THREAD_PRIORITY_BACKGROUND);
|
||||
thread.start();
|
||||
});
|
||||
}
|
||||
|
||||
private static void schedule(Context context, boolean sync) {
|
||||
|
||||
Reference in New Issue
Block a user