草庐IT

target-async

全部标签

multithreading - Spring @Async 限制线程数

我的问题与这个问题非常相似:@Asyncpreventathreadtocontinueuntilotherthreadhavefinished基本上我需要在更多线程中运行〜数百次计算。我只想运行一些并行线程,例如5线程5计算并行。我正在使用spring框架,@Async选项是自然的选择。我不需要功能齐全的JMS队列,这对我来说有点开销。有什么想法吗?谢谢 最佳答案 如果你使用Spring的Java配置,你的配置类需要实现AsyncConfigurer:@Configuration@EnableAsyncpublicclassApp

spring - 何时使用 Spring @Async vs Callable Controller (异步 Controller ,servlet 3)

我想知道在Spring中使用Callable使用@Async和Servlet3异步请求实现的一般用例。据我了解,@Async用于使任何方法(特别是任何服务方法)异步执行。@AsyncvoiddoSomething(Strings){//thiswillbeexecutedasynchronously}以及任何返回Callable的Controller@RequestMapping("/view")publicCallablecallableWithView(finalModelmodel){returnnewCallable(){@OverridepublicStringcall()t

java - 什么原因导致 "java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ' 命令'可用作请求属性”?

这是针对这些类型问题的广泛规范问答帖子。我正在尝试编写一个SpringMVCWeb应用程序,用户可以在其中将电影名称添加到内存集合中。它是这样配置的publicclassApplicationextendsAbstractAnnotationConfigDispatcherServletInitializer{protectedClass[]getRootConfigClasses(){returnnewClass[]{};}protectedClass[]getServletConfigClasses(){returnnewClass[]{SpringServletConfig.cl

java - Spring @Async 不工作

安@Async@Service中的方法-注解的类没有被异步调用——它阻塞了线程。我有在我的配置中,对方法的调用来自类外部,因此应该命中代理。当我单步执行代码时,代理确实被命中了,但它似乎并没有靠近与在任务执行器中运行相关的任何类。我在AsyncExecutionInterceptor中设置了断点他们永远不会受到打击。我已经调试到AsyncAnnotationBeanPostProcessor并且可以看到正在应用的建议。服务被定义为一个接口(interface)(带有注释的方法@Async用于很好的衡量标准),实现的方法注释为@Async也。两者均未标记@Transactional.任何

dart - 好或坏 : Declaring main method async in Dart/Flutter

我在整个app中声明了一个全局变量——SharedPreferencesprefs,并在main方法中初始化。但是,SharedPreferences初始化返回一个Future-因此我尝试等待它在应用程序的main关闭中得到解决:SharedPreferencesprefs;voidmain()async{prefs=awaitSharedPreferences.getInstance();runApp(MyApp());}而且效果很好。我目前在生产中的2个应用程序中使用此方法,我突然想到使main方法异步可能是不正确的。最后我有两个问题:main方法是如何被调用的,以及它在Dart/

node.js - 使用 es7 async/await 检查 mongodb 中是否存在文档

我正在尝试检查提供email的用户是否存在于集合users中,但我的函数每次调用都会返回undefined。我使用es6和async/await来摆脱大量回调。这是我的函数(它在一个类中):asyncuserExistsInDB(email){letuserExists;awaitMongoClient.connect('mongodb://127.0.0.1:27017/notificator',(err,db)=>{if(err)throwerr;letcollection=db.collection('users');userExists=collection.find({ema

node.js - 使用 es7 async/await 检查 mongodb 中是否存在文档

我正在尝试检查提供email的用户是否存在于集合users中,但我的函数每次调用都会返回undefined。我使用es6和async/await来摆脱大量回调。这是我的函数(它在一个类中):asyncuserExistsInDB(email){letuserExists;awaitMongoClient.connect('mongodb://127.0.0.1:27017/notificator',(err,db)=>{if(err)throwerr;letcollection=db.collection('users');userExists=collection.find({ema

flutter | Dart : Target of URI does not exist

我正在制作我的第一个应用程序,以使用Flutter构建Android应用程序。我正在使用AndroidStudio作为IDE。问题是当我导入http包时:import'package:http/http.dart'ashttp;我收到一个错误:error:TargetofURIdoesn'texist:'package:http/http.dart'.(uri_does_not_existat[flutter_crypto]lib\home_page.dart:3)这是我的代码:FuturegetCurrencies()async{StringcryptoUrl="https://ap

ios - 如何在 Flutter 中制作多个 iOS Target?

如何让Flutter为iOS运行一个不是默认“Runner”的Target? 最佳答案 这会很棘手。如果您查看flutterrun--help命令的输出,您会发现它支持自定义--flavor选项,该选项允许您指定自定义方案。然而,为了让它发挥作用,需要做几件事:在Xcode中打开您的工作区-从您应用的根目录在终端中运行openios/Runner.xcworkspace。通过展开项目和目标列表、单击Runner项目并选择复制(moredetailshere)来克隆Runner目标。这也应该为您创建一个自定义方案,带有自己的Info.

dart - Dart 中的 async 和 async* 有什么区别?

我正在使用flutter框架制作应用程序。在此期间,我遇到了Dartasync和async*中的关键字。谁能告诉我它们有什么区别? 最佳答案 简答async给你一个Futureasync*为您提供Stream。异步您将async关键字添加到执行某些可能需要很长时间的工作的函数中。它返回包装在Future中的结果。FuturedoSomeLongTask()async{awaitFuture.delayed(constDuration(seconds:1));return42;}您可以通过等待Future获得该结果:main()asy