Is Set growth thread-safe?

Bert Freudenberg bert at impara.de
Wed Sep 21 14:15:34 UTC 2005


Am 21.09.2005 um 07:15 schrieb Ross Boylan:

> I thought smalltalk was supposed to be thread-safe with respect to its
> own threads.  Am I mistaken in that belief, or in my analysis that the
> operation is not thread safe?

It's not safe. You need to protect concurrent access to all objects  
that are not specifically designed for thread-safety (like  
SharedQueues):

     "init"
     sema := Semaphore forMutualExclusion.
     set := Set new.

     "in threaded code"
     sema critical: [set add: something].


- Bert -




More information about the Squeak-dev mailing list