目录

shutdown-agents

此函数用于关闭所有正在运行的代理。

语法 (Syntax)

以下是语法。

(shutdown-agents)

Parameters - 无。

Return Value - 无。

例子 (Example)

以下程序显示了如何使用它的示例。

(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)

输出 (Output)

上述程序产生以下输出。

0
Incrementing Counter
0

上述程序的主要区别在于,程序现在将终止,因为所有代理都将正常关闭。

↑回到顶部↑
WIKI教程 @2018