DEV Community

Cover image for Programming in Clojure (Part 7 Concurrency)
Mark Mahoney
Mark Mahoney

Posted on • Edited on

Programming in Clojure (Part 7 Concurrency)

This post covers concurrency in Clojure. This is a big topic. I start by discussing threads. Then I talk about different strategies for dealing with data that is shared among different threads.

Concurrency

Call to Action

Problem 1
This lab asks you to create a Clojure program that will count how many primes are in a given range. Create a thread pool and have each thread check a single number in the range. If it finds a prime it will increase a counter (which should be an atom since it is shared by all of the threads). Look at the program above on Atoms as a starting point

Comments and Feedback

You can find all of these code playbacks in my free 'book', An Animated Introduction to Clojure. I am always looking for feedback so please feel free to comment here or to send me a message. You can follow me on twitter @markm208.

no website in cookie, Please visit a website first,cookie:{"ahoy_visit":"0ea8e222-31db-43a4-837e-a2977c35605f","ahoy_visitor":"54e1eb3d-79e4-4a84-af8b-f8ee4dccb392","_gh_sess":"zNMg8MEa123qdbeWvmoGluiQNxsthh9fytRN60t9wNiiMUjkLRFqxz5JNV3NQvEq%2BRFbB5R65U7n6hDDFsmB1gTqbXJyHXQxi5vawkEz2yAN8dkWzoDmYDbD%2F%2FHsieuxRVFWIGKKqvWb%2BvctAleARZukwtWOvG6wAqronbP8roeF52VgMxgY2W2gnjDzbVBQNw1gSKNLrPZRTXwJXxoYJythzbjQQu7oAJS%2F4j9tzFz2rnIooc3kj79WA0L1C7NcX%2FkiLxVoMIKKjoVEkKMNIA%3D%3D--OsjZhkUq0%2FeeWJXH--119U10UR%2BCR8futhmF84sw%3D%3D"}, website: undefined

Top comments (0)

no website in cookie, Please visit a website first,cookie:{"ahoy_visit":"0ea8e222-31db-43a4-837e-a2977c35605f","ahoy_visitor":"54e1eb3d-79e4-4a84-af8b-f8ee4dccb392","_gh_sess":"zNMg8MEa123qdbeWvmoGluiQNxsthh9fytRN60t9wNiiMUjkLRFqxz5JNV3NQvEq%2BRFbB5R65U7n6hDDFsmB1gTqbXJyHXQxi5vawkEz2yAN8dkWzoDmYDbD%2F%2FHsieuxRVFWIGKKqvWb%2BvctAleARZukwtWOvG6wAqronbP8roeF52VgMxgY2W2gnjDzbVBQNw1gSKNLrPZRTXwJXxoYJythzbjQQu7oAJS%2F4j9tzFz2rnIooc3kj79WA0L1C7NcX%2FkiLxVoMIKKjoVEkKMNIA%3D%3D--OsjZhkUq0%2FeeWJXH--119U10UR%2BCR8futhmF84sw%3D%3D"}, website: undefined
no website in cookie, Please visit a website first,cookie:{"ahoy_visit":"0ea8e222-31db-43a4-837e-a2977c35605f","ahoy_visitor":"54e1eb3d-79e4-4a84-af8b-f8ee4dccb392","_gh_sess":"zNMg8MEa123qdbeWvmoGluiQNxsthh9fytRN60t9wNiiMUjkLRFqxz5JNV3NQvEq%2BRFbB5R65U7n6hDDFsmB1gTqbXJyHXQxi5vawkEz2yAN8dkWzoDmYDbD%2F%2FHsieuxRVFWIGKKqvWb%2BvctAleARZukwtWOvG6wAqronbP8roeF52VgMxgY2W2gnjDzbVBQNw1gSKNLrPZRTXwJXxoYJythzbjQQu7oAJS%2F4j9tzFz2rnIooc3kj79WA0L1C7NcX%2FkiLxVoMIKKjoVEkKMNIA%3D%3D--OsjZhkUq0%2FeeWJXH--119U10UR%2BCR8futhmF84sw%3D%3D"}, website: undefined