r/Clojure • • May 31 '25
Using channels for concurrency
Hi everyone, I've recently read about channels and the go function in clojure for concurrency. I have some experience with go, and as such I find this solution to concurrency quite intuitive. However, I was wondering if it's really used in practice or there are different solutions that are more idiomatic?
23
Upvotes
View all comments
Show parent comment
4
u/thheller May 31 '25
Yes, it'll block the thread. With Java21+ you can use Virtual Threads, which essentially act like
go, in that they are cheap and don't map 1:1 to OS threads, and blocking them is fine.That being said, I have worked with thousands of regular threads without issue. It does require a bit of thinking through how threads are utlilized, but unless you are planning on millions of threads it matters much less than one may think on modern hardware. A blocked thread just consumes a little more resources than a parked one essentially.
If you are approaching that scale tiny things began to matter, and I'm not qualified to talk that since I've never built something like that.