此函数用于关闭所有正在运行的代理。
(shutdown-agents)
以下程序显示了有关如何使用它的示例。
链接:https://www.learnfk.comhttps://www.learnfk.com/clojure/clojure-shutdownagents.html
来源:LearnFk无涯教程网
(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)
上面的程序产生以下输出。
0 Incrementing Counter 0
上面程序的主要区别在于,该程序现在将终止,因为所有代理都将正确关闭。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)