-
Book Overview & Buying
-
Table Of Contents
Clojure for Java Developers
Knowing Java and your way around Java's threading APIs gives you a great advantage, since Clojure relies on the tools that you already know.
Here, you'll see how to use threads and you can extend everything you see here to execute other services.
Before going any further, let's create a new project that we'll use as a sandbox for all of our tests.
Create it, as shown in the following screenshot:

Modify the clojure-concurrency.core namespace, so that it looks similar to the following code snippet:
(ns clojure-concurrency.core) (defn start-thread [func] (.start (Thread. func)))
It's easy to understand what's happening here. We are creating a thread with our function and then starting it; so that we can use it in the REPL, as follows:

java.lang.Thread has a constructor, which receives an object implementing the runnable interface. You can just pass a Clojure function because every function in Clojure implements runnable and callable interfaces. This means that you...
Change the font size
Change margin width
Change background colour