男孩的卧室,毕业设计封面,惑心弃妃
用于链式执行跨线程代码,且传递数据
task.call(new callable<boolean>() { @override public boolean call() throws exception { return true; } }, task.ui_thread_executor); task.callinbackground(new callable<boolean>() { @override public boolean call() throws exception { return false; } }); task.callinbackground(new callable<boolean>() { @override public boolean call() throws exception { return true; } }).onsuccess(new continuation<boolean, object>() { @override public object then(task<boolean> task) throws exception { if (task.getresult()) { return null; } else { return new object(); } } }, task.background_executor).continuewith(new continuation<object, object>() { @override public object then(task<object> task) throws exception { if (task.getresult() == null) { toast.maketext(getbasecontext(), "null", toast.length_short).show(); } else { toast.maketext(getbasecontext(), "not null", toast.length_short).show(); } return null; } }, task.ui_thread_executor);
在内部通过维护多中 executorservice 对象,并且通过串联的方式进行调用。
并且通过维护内部变量在,在指定流程处,就是特定的,值,值通过task的对象getresult拿到。
uithread
/** * 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); } }
backgroundthread
private boltsexecutors() { background = !isandroidruntime() ? java.util.concurrent.executors.newcachedthreadpool() : androidexecutors.newcachedthreadpool(); scheduled = executors.newsinglethreadscheduledexecutor(); immediate = new immediateexecutor(); }
implementation 'com.parse.bolts:bolts-android:1.2.0'
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio开发小型对话机器人app(实例代码)
Android通过Java sdk的方式接入OpenCv的方法
Android 通过cmake的方式接入opencv的方法步骤
Android Studio finish()方法的使用与解决app点击“返回”(直接退出)
Android 进度条 ProgressBar的实现代码(隐藏、出现、加载进度)
网友评论