[Ecls-list] Multithreaded globals
Juan Jose Garcia Ripoll
lisp at arrakis.es
Mon Nov 7 05:59:02 UTC 2005
On Tue, 2005-11-08 at 00:43 +1100, Dean O'Connor wrote:
> For example, in the code below, if each of my threads called start(),
> straight away binding a newly created class object to that dynamic
> variable, is that threadsafe on a multi-cpu machine ?
> Or do I *need* some mutexing to guarantee no clobbering ?
> (defun start ()
> (let ((*MyObj* (make-instance 'MyClass)))
> (setf (field *MyObj*) "stuff")
> (work)))
As I said before, LET/LET*/DO... bindings are local to each thread. You
need no mutex variables. However, a value set on the toplevel by a
DEFPARAMETER or DEFVAR form will be seen by all threads.
Juanjo
More information about the ecl-devel
mailing list