JAVA 原生异步执行方法CompletableFuture
2018-04-14 18:45:39
1138 次阅读
0 个评论
使用CompletableFuture的静态工厂方法
/**
* 测试异步调用
*
*/
@WebServlet("/test")
public class FilePackageManageAction extends HttpServlet{
private static final long serialVersionUID = -2939886433910373111L;
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//异步调用
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
System.out.println("异步调用方法");
});
}
}
00