来自Callable的CompletableFuture?(CompletableFuture from Callable?)
今天,我尝试了来自Java 8的“新”
CompletableFuture
,发现自己在找不到runAsync(Callable)
方法时感到困惑。 我可以自己做,如下所示,但为什么这(对我来说非常明显和有用的实用方法)缺失? 我错过了什么吗?public static <T> CompletableFuture<T> asFuture(Callable<? extends T> callable, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { try { future.complete(callable.call()); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; }
Today I experimented with the "new"
CompletableFuture
from Java 8 and found myself confused when I didn't find arunAsync(Callable)
method. I can do it myself like shown below, but why is this (to me very obvious and useful utility method) missing? Am I missing something?public static <T> CompletableFuture<T> asFuture(Callable<? extends T> callable, Executor executor) { CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { try { future.complete(callable.call()); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; }
原文:https://stackoverflow.com/questions/30559707
更新时间:2023-11-23 18:11
最满意答案
$this->Html->script('scriptname');
并确保您的脚本位于webroot中的js文件夹中
$this->Html->script('scriptname');
And make sure your script is in the js folder in the webroot
相关问答
更多-
$this->Html->script('scriptname'); 并确保您的脚本位于webroot中的js文件夹中 $this->Html->script('scriptname'); And make sure your script is in the js folder in the webroot
-
有一个未公开的特性,如果您的options数组的值为0 ,则返回的结果将包含布局: $newsletter_html = $this->requestAction( array( 'controller' => 'Newsletters', 'action' => 'view' ), ...
-
从文档页面 (最后一行) 如果你想添加一个自定义元标记,那么第一个参数应该设置为一个数组。 要输出机器人noindex标签,请使用以下代码: echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex')); 在你的情况下: echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex, nofollow'),null,array('inline ...
-
您已安装CakePHP 应用程序模板的 3.0.3版,实际的CakePHP 框架有所不同(请参阅bin/cake --help或vendor/cakephp/cakephp/VERSION.txt )。 建议您提及两个版本! 除非你知道你在做什么,也就是说你知道如何迁移代码,否则不要使用针对旧版本的问题/答案,教程等。 您链接到的问题是关于CakePHP 1.3,它与它不兼容。 您正在查看默认主页(通过现成的页面控制器提供 ),它会使用$this->layout = false;显式关闭布局使用情况 $th ...
-
Cakephp TinyMce(Cakephp TinyMce)[2022-01-17]
我无法得到上面的帮助,所以我尝试了CakeDC制作的这个插件解决了这个问题: https : //github.com/CakeDC/TinyMCE 在app / plugin目录中提取文件后,您只需要在控制器中添加一个类似于以下内容的帮助程序: public $helpers = array('TinyMCE.TinyMCE'); 在/app/config/bootstrap.php文件中,我添加了: CakePlugin::load('TinyMCE'); ... Configure::write ... -
CakePHP - 布局和视图(CakePHP - layout and view)[2021-06-05]
如果您想要在多个不同视图中重复使用某些HTML,则可以使用元素。 在“/ app / view / Elements”文件夹中创建.ctp文件。 例如,“/ app/view/Elements/loginform.ctp”。 在该文件中,您将创建登录表单。 视图中的所有可用内容都可在此文件中找到(例如HTML Helper)。 要插入此元素,只需执行echo $this->element('loginform'); 。 您可以在视图文件或布局文件中执行此操作。 If you want to have som ... -
CakePHP - 只是布局?(CakePHP - Just Layout?)[2023-10-02]
@happyontbelong的解决方案有效。 您还可以为ajax创建布局和视图。 您的布局可能是这样的: 然后你可以像这样创建一个ajax视图: Js->object($result);?> 然后从你的控制器...... public function savecontent(){ $this->autoRender = false; $this->set('result', fal ... -
CakePHP 3:将特定的JS / CSS文件添加到特定的视图(CakePHP 3: Add specific JS/CSS file to a specific view)[2023-08-04]
转到您的index.ctp文件并在底部插入此代码。 对于JS echo $this->Html->script('/otherdir/scripts'); 要么 echo $this->Html->script('http://code.jquery.com/jquery.min.js'); 会输出: 第一个参数可以是包含多个文件的数组。 echo $this->Html->scr ... -
您需要添加一个调用ShowToolWindow例程的命令。 包vsct文件的顶部需要一些外部引用:
Cakephp 3中的布局?(Layout in Cakephp 3?)[2024-01-10]
您需要在Controller设置布局或定义应在/src/View/AppView.php中加载前端View一些条件。 查看文档 。 对于Controller方法: // Set the layout. $this->viewBuilder()->setLayout('admin'); // Before 3.4 $this->viewBuilder()->layout('admin'); // Before 3.1 $this->layout = 'admin'; You need the set t ...相关文章
更多- Callable接口实现Java多线程
- Python内建函数(C)
- mybatis 调用 mysql 存储过程 返回结果集
- 试玩 PHP 5.4 的新特性
- 利用Java操作Git获取分支的内容
- Guava学习笔记:Guava cache
- solr dataimport 数据导入源码分析(九)
- 一次针对批量查询处理的优化
- Solr从Mongodb索引数据(上) 借助mongodb-jdbc和配置JdbcDataSource
- 传智播客_张孝祥_Java多线程与并发库高级应用视频教程下载
最新问答
更多- h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
- 创建一个功能(Create a function)
- 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
- PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
- Qt冻结循环的原因?(Qt freezing cause of the loop?)
- TableView重复youtube-api结果(TableView Repeating youtube-api result)
- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
- 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
- 以编程方式创建UITableView(Creating a UITableView Programmatically)
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
- Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
- 设置kotlin扩展名(Setting a kotlin extension)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 如何在vim中启用python3?(How to enable python3 in vim?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- dedecms如何安装?
- 在哪儿学计算机最好?
- 学php哪个的书 最好,本人菜鸟
- 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
- 如何覆盖错误堆栈getter(How to override Error stack getter)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
- 电脑高中毕业学习去哪里培训
- 正则表达式验证SMTP响应(Regex to validate SMTP Responses)