| Error 2014-04-29 11:10:24,125 [Actor Thread 28] ERROR gpars.LoggingPoolFactory - Async execution error: nullMessage: null line | Method->> 61 | doCall in org.grails.async.factory.gpars.GparsPromise$_onComplete_closure1- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 62 | run in groovyx.gpars.dataflow.DataCallback| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker^ 724 | run . . . in java.lang.Thread
请帮我解决这个问题.
这是守则
//Promise 1 Promise p1 = task { println ID+" p1 Task is Runing" sleep(4000) println ID+" p1 Thread Woke Up" return "p1Completed" } //Promise 2 Promise p2 = task { println ID+" p2 Task is Runing" sleep(4000) println ID+" p2 Thread Woke Up" return "p2Completed" } p1.onComplete { result -> println ID+" Promise p1 Completed returned "+result } p1.onError { Throwable err -> println ID+" p1 An error occured ${err.message}" } p2.onComplete { result -> println ID+" Promise p2 Completed returned "+result } p2.onError { Throwable err -> println ID+" p2 An error occured ${err.message}" }解决方法 您需要在代码底部添加以下行:
p1.get()p2.get()
这将阻止请求,直到两个承诺都完成.如果要运行异步任务并在不同步等待响应的情况下结束请求,则需要使用java executor框架.检查这个问题:Error on async job
总结以上是内存溢出为你收集整理的Grails中的异步编程全部内容,希望文章能够帮你解决Grails中的异步编程所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)