From: Dmitry Kalyanov on
On Nov 28, 11:35 pm, Bing <bernd.beus...(a)googlemail.com> wrote:
> I tinkered with SBCL threads:
>
>                         for i below nthreads
>                         collect (sb-thread:make-thread
>                                  (lambda () (thread-fn i start end))
These two lines are guilty. You are passing are closure to the thread.
The closure is closed over variables that change. And because threads
execute (possible) concurrently, one thread (the one with the loop)
may change the variables before the newly created thread has read
them. Changing it to something like this should fix it:

(let ((i i) (start start) (end end))
(sb-thread:make-thread (lambda () (thread-fn i start end))))

(this ensure that thread function does not close over loop variables)
From: Giovanni Gigante on
Bing wrote:
> Is it correct to write to an array without mutex?

There was some discussion on thread-safe operations in SBCL here:
http://sourceforge.net/mailarchive/forum.php?thread_name=633d72b0911110916x6e3e7cd6la6dee84bd6798d6c%40mail.gmail.com&forum_name=sbcl-help
Not sure if this applies to your case, though.