此函数用于关闭所有正在运行的代理。
(shutdown-agents)
以下程序显示了有关如何使用它的示例。
(ns clojure.examples.example (:gen-class)) (defn Example [] (def counter (agent 0)) (println @counter) (send counter + 100) (println "Incrementing Counter") (println @counter) (shutdown-agents)) (Example)
上面的程序产生以下输出。
链接:https://www.learnfk.comhttps://www.learnfk.com/clojure/clojure-shutdownagents.html
来源:LearnFk无涯教程网
0 Incrementing Counter 0
上面程序的主要区别在于,该程序现在将终止,因为所有代理都将正确关闭。
这一章《Clojure - 代理 - shutdown-agents函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持