# File lib/facet/multiton.rb, line 146
    def  selfself..append_featuresappend_features(klass)
      def klass.instance(*args, &block)
        # if the class defined 'multiton_id' we use this as the key
        # otherwise we simply use the argument list.
        k = (respond_to?(MULTITON_ID_HOOK) ? send(MULTITON_ID_HOOK, *args, &block) : args)
        unless (obj = (POOLS[self] ||= {})[k])
          begin
            critical = Thread.critical
            Thread.critical = true
            meth = self.respond_to?(MULTITON_NEW_HOOK) ? MULTITON_NEW_HOOK : :new
            obj = (POOLS[self][k] = self.send(meth, *args, &block))
          ensure
            Thread.critical = critical # restore state
          end
        end
        return obj
      end
    end