store/[org.clojure/clojure "1.8.0"] clj::clojure.core/shutdown-agents

Official Documentation

Add notes
Arities
==================================================
   []

Docstring
==================================================
  Initiates a shutdown of the thread pools that back the agent
  system. Running actions will complete, but no new actions will be
  accepted

Source

(defn shutdown-agents
  "Initiates a shutdown of the thread pools that back the agent
  system. Running actions will complete, but no new actions will be
  accepted"
  {:added "1.0"
   :static true}
  [] (. clojure.lang.Agent shutdown))

Example 1

Edit
;; Create the agent that we will be using
(def a (agent 0))
;; => #'user/a

;; Dereference the agent to show the value is 0
@a
;; => 0

;; Create a function that can increment the agent
;; This will continually update the value of the agent
(defn agent-inc [a]
  (send-off *agent* agent-inc)
  (inc a))
;; => #'user/agent-inc

;; Send the agent to the agent-inc function
;; The value is 188 because by the time the repl has sent off the
;; agent to the function, the function has already been called recursively
(send a agent-inc)
;; => #<Agent@6b850d: 188>

;; Dereference of the value a second or so later
@a
;; => 716889

;; Another dereference in another couple of seconds
@a
;; => 1455264

;; Shutdown the threads for the agents
(shutdown-agents)
;; => nil

;; Dereference the agent to see what value it is
@a
;; => 3522353

;; Dereference the agent again in a few seconds
;; It's the same value, because the agent pool of threads are no longer
;; active
@a
;; => 3522353

Example 2

Edit
;; Creating an agent
(def a (agent 1))
;; => #'user/a

;; Create a function that can handle an agent

(defn agent-action [a]
  33)
;; => #'user/agent-action

;; The agent will become 33
(send-off a agent-action)
;; => #<Agent@dde4f2: 33>

@a
;; => 33
;; Create another agent before shutdown
(def c (agent 3))
;; => #'user/c

;; Shutdown agents is called
(shutdown-agents)
;; => nil

;; Attempt to turn c into 33
(send c agent-action)
;; => #<Agent@b162fa: 3>

;; The result is that it is still the same value it was initialized with
@c
;; => 3

;; Agent created after shutdown
(def d (agent 4))
;; => #'user/d

;; Try sending it
(send d agent-action)
;; => #<Agent@356519: 4>

;; Same thing, there are no threads to process the agents
@d
;; => 4

Uses on crossclj