Summary
In general, thread
with its channel return will likely be more convenient for the parts of your application where channels are prominent. On the other hand, any subsystems in your application that interface with some channels at their boundaries but don't use core.async internally should feel free to launch threads in whichever way makes the most sense for them.
Differences between thread
and future
As pointed out in the fragment of the core.async blog post you quote, thread
returns a channel, just like go
:
(let [c (thread :foo)]
(<!! c))
;= :foo
The channel is backed by a buffer of size 1 and will be closed after the value returned by the body of the thread
form is put on it. (Except if the returned value happens to be nil
, in which case the channel will be closed without anything being put on it -- core.async channels do not accept nil
.)
This makes thread
fit in nicely with the rest of core.async. In particular, it means that go
+ the single-bang ops and thread
+ the double-bang ops really are used in the same way in terms of code structure, you can use the returned channel in alt!
/ alts!
(and the double-bang equivalents) and so forth.
In contrast, the return of future
can be deref
'd (@
) to obtain the value returned by the future
form's body (possibly nil
). This makes future
fit in very well with regular Clojure code not using channels.
There's another difference in the thread pool being used -- thread
uses a core.async-specific thread pool, while future
uses one of the Agent-backing pools.
Of course all the double-bang ops, as well as put!
and take!
, work just fine regardless of the way in which the thread they are called from was started.