code_junkie

Calling Java from Clojure

Nov 12th, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. (dotimes [i 5]
  2. (.start
  3. (Thread.
  4. (fn []
  5. (Thread/sleep (rand 1000))
  6. (println (format "Finished %d on %s" i (Thread/currentThread)))))))
  7.  
  8. java.lang.Exception: Unable to resolve symbol: i in this context
  9. clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:6: Unable to resolve symbol: i in this context
  10. at clojure.lang.Compiler.analyze(Compiler.java:3713)
  11.  
  12. user> (dotimes [i 5] (.start (Thread. (fn [] (Thread/sleep (rand 1000)) (println (format "Finished %d on %s" i (Thread/currentThread)))))))
  13.  
  14. Finished 0 on Thread[Thread-16,5,main]
  15. Finished 4 on Thread[Thread-20,5,main]
  16. Finished 3 on Thread[Thread-19,5,main]
  17. Finished 1 on Thread[Thread-17,5,main]
  18. Finished 2 on Thread[Thread-18,5,main]
Add Comment
Please, Sign In to add comment