From: "Jan E." Date: 2012-11-28T01:20:36+09:00 Subject: Re: why this behaves like singleton Hi, a class variable (in your case @@locks) is shared among the class and all instances of the class -- as well as all subclasses and their instances. So when g1 or g2 do something with @@locks, it's always the same array. I think you generally misunderstand the difference between the various types of variables. For example, the variable @lock in @lock = 0 is completely different from the one you use in the initialize method, and in your case it's simply useless. Ruby is not Java where this syntax is used to set default values. So you might wanna read up on this topic: http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Classes You should generally avoid class variables unless you really know what you're doing. Use instance variables or class instance variables depending on the specific purpose. To fix your code, replace @@locks with an instance variable and set it in the correct context: ---------------------------- class Locks def initialize ( rd ) @locks = [] rd.each do |k| @locks << Lock.new(rd) end end def printLocks @locks.each do |l| puts l.glock() end end end ---------------------------- -- Posted via http://www.ruby-forum.com/.