Class variables not thread-safe?

i’m trying make an API available via DRb and/or ROMP. both bomb. DRb
gets further then ROMP but complains about a class variable. the API
works fine on its own (ie. without DRb or ROMP). i’m guessing my API’s
not thread-safe, but i’m not sure what factors make something
thread-safe or not really. does my use of class variables do that? or is
there something else going on?

~transami

Tom Sawyer wrote:

i’m guessing my API’s
not thread-safe, but i’m not sure what factors make something
thread-safe or not really. does my use of class variables do that?

Access to mutator methods (methods that change state) on a object from
several threads of execution will make your code non-thread-safe. Class
variables tend to be available to all instances of the class, and if you
then have instances of the class in various threads, you are very likely
to run into threading issues.

You’ll probably need to guard the access to the class variables. Take a
look at the Mutex class. The PickAxe chapter should tell you most of
what you need to know. (
http://www.rubycentral.com/book/tut_threads.html )

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 4. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)