[armedbear-devel] threads, join, clos

David Kirkman dkirkman at ucsd.edu
Sat Apr 24 04:52:24 UTC 2010


Is there an equivalent of java.lang.Thread.join() on the lisp side of
things?  I looked around in LispThread.java and threads.lisp, but I
don't see anything obvious.  I'd like to be able to write something

(let ((threads (loop for i from 0 to 5
                    (make-thread #'(lambda()
                                     (format t "hey~%"))))))
  (mapc #'thread-join threads)
  (format t "is for horses~%"))

I've attached a patch that implements this version of thread-join.  It
implements java semantics, this thread-join always returns nil.  I
guess java doesn't really have a way to return arbitrary values, but
we easily do!  I was thinking about hacking it up a bit more so that
thread-join would return the value of the function passed to
make-thread, e.g. so that

(thread-join (make-thread #'(lambda () 1)))

would return 1.  But then it occurred to me that this functionality is
probably already in there under a different name.  So, how do you guys
join your threads?


-david k.

P.S.  Are there any known thread safety issues with CLOS?  I've been
getting some weird MOP errors that I made go away by redefining
slot-value such that it has to acquire a global lock before it can do
anything.  I assume that the problem is in my code: but the threads
that are executing when I get the failures share no code (or
variables), and every time the errors pop up slot-value is on the
callstack someplace.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: thread-join.diff
Type: application/octet-stream
Size: 1025 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20100423/08ba94df/attachment.obj>

More information about the armedbear-devel mailing list