本文介绍了Clojure中的未来承诺挂在我身上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行下面的代码它基本上是如何打算,除非它挂在未来完成后。我缺少什么 - 某种关闭代理/线程调用?
When I run the following code it basically works how I intend it to, except that it hangs after the future is finished. What am I missing - some kind of "close agents/threads" call? How should I do this?
(def name-to-greet (promise)) (future (println "Hello," @name-to-greet)) (print "What is your name? ") (flush) (deliver name-to-greet (read-line))推荐答案
Futures使用代理线程池,它使用非守护线程,这意味着Clojure不会关闭,直到你调用(shutdown-agents)。 imho,this is bogus(see 我在这里的评论)和我提出的建议,Rich说他会考虑后1.2关于这一点。
Futures use the agent thread pool, which uses non-daemon threads, which means Clojure won't shut down till you call (shutdown-agents). imho, this is bogus (see my comments here) and I've made suggestions that Rich said he would consider post-1.2 around this.
更多推荐
Clojure中的未来承诺挂在我身上
发布评论