andorid jar/库源码解析之Bolts
2021-01-29 11:16
标签:exec cache cal schedule 流程 runnable androi throw ice 目录:andorid jar/库源码解析 用于链式执行跨线程代码,且传递数据 在内部通过维护多中 ExecutorService 对象,并且通过串联的方式进行调用。 并且通过维护内部变量在,在指定流程处,就是特定的,值,值通过Task的对象getResult拿到。 UIThread BackgroundThread andorid jar/库源码解析之Bolts 标签:exec cache cal schedule 流程 runnable androi throw ice 原文地址:https://www.cnblogs.com/Supperlitt/p/12833462.htmlBolts:
作用:
栗子:
Task.call(new Callable
源码解读:
/**
* An {@link java.util.concurrent.Executor} that runs tasks on the UI thread.
*/
private static class UIThreadExecutor implements Executor {
@Override
public void execute(Runnable command) {
new Handler(Looper.getMainLooper()).post(command);
}
}
private BoltsExecutors() {
background = !isAndroidRuntime()
? java.util.concurrent.Executors.newCachedThreadPool()
: AndroidExecutors.newCachedThreadPool();
scheduled = Executors.newSingleThreadScheduledExecutor();
immediate = new ImmediateExecutor();
}
源码:https://github.com/BoltsFramework/Bolts-Android
引入:
implementation ‘com.parse.bolts:bolts-android:1.2.0‘
文章标题:andorid jar/库源码解析之Bolts
文章链接:http://soscw.com/index.php/essay/48660.html