pull/50/head
M66B 6 years ago
parent e891b42382
commit cb25ccc175

@ -109,6 +109,8 @@ import androidx.lifecycle.LifecycleService;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
public class ServiceSynchronize extends LifecycleService { public class ServiceSynchronize extends LifecycleService {
private final Object lock = new Object(); private final Object lock = new Object();
private ServiceManager serviceManager = new ServiceManager(); private ServiceManager serviceManager = new ServiceManager();
@ -1451,6 +1453,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
} }
}, "sync.main"); }, "sync.main");
main.setPriority(THREAD_PRIORITY_BACKGROUND); // will be inherited
main.start(); main.start();
} }

@ -33,6 +33,8 @@ import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleService; import androidx.lifecycle.LifecycleService;
import androidx.lifecycle.OnLifecycleEvent; import androidx.lifecycle.OnLifecycleEvent;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
// //
// This simple task is simple to use, but it is also simple to cause bugs that can easily lead to crashes // This simple task is simple to use, but it is also simple to cause bugs that can easily lead to crashes
// Make sure to not access any member in any outer scope from onLoad // Make sure to not access any member in any outer scope from onLoad
@ -50,6 +52,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
static { static {
handlerThread = new HandlerThread("SimpleTask"); handlerThread = new HandlerThread("SimpleTask");
handlerThread.setPriority(THREAD_PRIORITY_BACKGROUND);
handlerThread.start(); handlerThread.start();
handler = new Handler(handlerThread.getLooper()); handler = new Handler(handlerThread.getLooper());
} }

Loading…
Cancel
Save