Clojure – shutdown-agents

Clojure shutdown-agents

In this guide, we will discuss Clojure Shutdown-agents. This function is used to shut down any running agents.

Syntax

Following is the syntax.

(shutdown-agents)

Parameters − None.

Return Value − None.

Example

An example on how this is used is shown in the following program.

(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

The above program produces the following output.

0
Incrementing Counter
0

The key difference in the above program is that, the program will now terminate since all agents will shut down properly.

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply