From: Robert Klemme Date: 2009-02-05T01:49:17+09:00 Subject: Re: Using a Class (not an instance) into threads 2009/2/4 Iņaki Baz Castillo : > 2009/2/4 Ilan Berci : > >> This is not an example of a "singleton class". It is merely a class >> with static methods which means that you don't have to make an instance >> prior to using it. Actually there is no such thing as a "static method". This term belongs to Java, C++ and probably other languages. The attribute was defined on the singleton class of instance MyParser which happens to be a class. So, Inaki, yes this state does only exist once and if you change it concurrently you're in trouble. > Thanks for pointing it out. > When defining an attribute into "class << self [..] end" it means that > it is an instance attribute of the class (since in Ruby a Class is > also an instance). I though that *this* was called "Singleton". "Singleton" is a general term denoting things where you have only one from. A "Singleton Class" in Ruby is the class which you obtain when doing class <> If the class that Ragel populated has no state >> (which I don't believe it does) then it can safely be used in a threaded >> context. > > During a method into MyParser class, there are *a lot* of attributes > whose value change, and that value is important to remain when the > function ends, so I understand that the class that Ragel populated > does have state, am I wrong? I do not know Ragel but it may well be that the class that Ragel created has only immutable state necessary for the parser and that the parsing related state is in instances of that class. Can you post more of MyParser? Cheers robert -- remember.guy do |as, often| as.you_can - without end