Clojure shutdown-agents

2018-12-27 15:08 更新

此功能用于關(guān)閉所有正在運行的代理。

語法

以下是 shutdown-agents 基本語法:

(shutdown-agents)

參數(shù) ? 空。

返回值 ? 空。

下面的程序顯示了如何使用 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)

輸出

以上示例輸出以下結(jié)果:

0
Incrementing Counter
0

上述程序的主要區(qū)別在于,由于所有代理都將正常關(guān)閉,程序現(xiàn)在將終止。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號