I have the following functions in my concurrent program:
(def time-format (new java.text.SimpleDateFormat "HH:mm:ss"))

(defn now []
  (new java.util.GregorianCalendar))

(defn give-message [message]
  (println (format "%s: %s" (. time-format format (. (now) getTime))
message)))


But sometimes a new message from a different thread is displayed, before
the current message is ready:
10:34:57: Different for      4194573 (9.313226e-10, 2.220304e-16)10:34:57:
Different for      4198042 (9.313226e-10, 2.218469e-16)

10:34:57: Different for      8389473 (1.862645e-09, 2.220217e-16)


Is there a way to make give-message atomic, so it would be displayed as:
10:34:57: Different for      4194573 (9.313226e-10, 2.220304e-16)
10:34:57: Different for      4198042 (9.313226e-10, 2.218469e-16)
10:34:57: Different for      8389473 (1.862645e-09, 2.220217e-16)


I attached the complete program. Any hints to implement it better are
appreciated.

-- 
Cecil Westerhof

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: check-power.clj
Description: Binary data

Reply via email to