Clojure中的未来承诺挂在我身上

编程入门 行业动态 更新时间:2024-10-23 07:32:45
本文介绍了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中的未来承诺挂在我身上

本文发布于:2023-11-25 02:46:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628013.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:挂在   身上   未来   Clojure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!