In the current Clojure version of core.async, the thread pool executor is located in the clojure.core.async.impl.dispatch
namespace. You can alter the executor
var and supply a custom thread pool ExecutorService
.
(ns sandbox
(:require [clojure.core.async.impl.concurrent :as conc]
[clojure.core.async.impl.exec.threadpool :as tp]
[clojure.core.async :as async]))
(defonce my-executor
(java.util.concurrent.Executors/newFixedThreadPool
1
(conc/counted-thread-factory "my-async-dispatch-%d" true)))
(alter-var-root #'clojure.core.async.impl.dispatch/executor
(constantly (delay (tp/thread-pool-executor my-executor))))
(async/go
(println
(Thread/currentThread))) ;=> #<Thread Thread[my-async-dispatch-1,5,main]>
Note: Core.async is still in alpha, so, hopefully, this will change in the future.