Re: Noobie question - sorry :)
On Tuesday, March 12, 2013 8:59:47 AM UTC+1, edw...@kenworthy.info wrote: > So I do not understand why calling > > (defn evolve [] > (Thread/sleep 1000) > (print ".") > (recur)) > > Never results in anything being printed until I press Ctrl-C at which > point a bunch of . are printed. > > However if I remove (Thread/sleep 1000) then it works as I would expect. > Actually it works the same in both cases: the dots are printed in chunks as large as the buffer size of the *out* writer. You just didn't have the patience to wait that many seconds :) Try with (Thread/sleep 1) and you'll see. I thought (Thread/sleep 1000) would basically wait for a second (allowing > other threads to run) and then continue but it *appears* to work as I would > expect but it blocks output (both to the console and, I think, to the > seesaw frame/canvas created separately). > It does work exactly as you expected: it allows other threads to run. You must be very careful in knowing exactly *which* thread it makes sleep. As for the console output, the real reason is as explained above. -- -- 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/groups/opt_out.
Re: Noobie question - sorry :)
Thank you. -- -- 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/groups/opt_out.
Re: Noobie question - sorry :)
2013/3/12 > So I do not understand why calling > > (defn evolve [] > (Thread/sleep 1000) > (print ".") > (recur)) > > Never results in anything being printed until I press Ctrl-C at which > point a bunch of . are printed. > > However if I remove (Thread/sleep 1000) then it works as I would expect. > > I thought (Thread/sleep 1000) would basically wait for a second (allowing > other threads to run) and then continue but it *appears* to work as I would > expect but it blocks output (both to the console and, I think, to the > seesaw frame/canvas created separately). > The output is buffered, try by adding a call to (flush) after each (print ".") HTH, -- Laurent -- -- 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/groups/opt_out.