-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
e.g.
public class AppExecutors {
private static final AppExecutors INSTANCE = new AppExecutors();
private final ExecutorService background;
private final Executor mainThread;
private AppExecutors() {
this.background = Executors.newCachedThreadPool();
this.mainThread = new MainThreadExecutor();
}
public static AppExecutors getInstance() {
return INSTANCE;
}
public ExecutorService background() {
return background;
}
public Executor mainThread() {
return mainThread;
}
private static class MainThreadExecutor implements Executor {
private final Handler mainThreadHandler = new Handler(Looper.getMainLooper());
@Override
public void execute(Runnable command) {
mainThreadHandler.post(command);
}
}
}Reactions are currently unavailable