From: "Iñaki Baz Castillo" Date: 2009-02-04T21:39:45+09:00 Subject: Using a Class (not an instance) into threads Hi, i'm using Ragel parser generating Ruby code. The generated code uses a Class instead of an instance, and that class has lots of attributes and methods. Something like: -------------- class MyParser class << self attr_accessor :_machine_trans_keys private :_machine_trans_keys, :_machine_trans_keys= end self._machine_trans_keys = [ 0, 0, 9, 34, 10, 10, 9, 32, 9, 34, -64, 126, -128, -65, -128, -65, -128, -65, -128, -65, -128, -65, 10, 10, 9, 32, 13, 13, 10, 10, 0, 127, 0, 0, 0 ] ... ... def self.run_machine(data) ... end end ------------- So I wonder how could I use this class into a threaded program. AFAIK a singleton class is the Class itself, so if a running thread modifies some singleton attribute then all the other threads will see that change (error!!!). Am I right? How could I achieve it? Thanks a lot. -- Iñaki Baz Castillo