On Fri, Jul 6, 2012 at 5:22 PM, grahamke <kgraha...@gmail.com> wrote:
> (.start (Thread. (println "I ran!") "tName"))

You're missing a # here. You create a new thread object passing two
args to the Thread constructor: The return value of (println ...) and
"tName". println returns nil, so you effectively do (Thread. nil
"tName").

The difference in behavior is, that the first version runs the println
in the repl thread BEFORE spawning a new thread (which doesn't do
anything in this case).

You want to pass a Runnable object (e.g. a function) as the first
argument: (.start (Thread. #(println "Ohai!"), "tName")). This will
create a new thread which will run the supplied function which will
print a message to the console.


Background threads usually print to the console because *out* etc.
isn't redirected to the REPL.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to