(defun mt-map (func sequence)
(mapcar
#'(lambda (elem)
(make-thread
#'(lambda () (apply func elem))))
sequence)
)
(mt-map #'1+ '(1 2 3))
;; => (#<thread 0x57f4550bdf08> #<thread 0x57f4550be110> #<thread 0x57f4550be318>)
(mapcar
#'(lambda (thrd) (thread-join thrd))
(mt-map #'1+ '(1 2 3)))
;; => (nil nil nil)
尝试写了一个多线程的例子,发现最后thread-join
那里拿不到返回值,从文档看thread-join
应该能够获取到线程的返回值,不知道哪里我理解的不对。求指点。
;; this also does not work!
(let ((thrd (make-thread
'(lambda () (+1 2)))))
(thread-join thrd))
;; => nil