此函数用于关闭所有正在运行的代理。
shutdown-agents - 语法
(shutdown-agents)
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)
上面的程序产生以下输出。
0 Incrementing Counter 0
上面程序的主要区别在于,该程序现在将终止,因为所有代理都将正确关闭。