You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: copy_on_notify_observer_set.rb
    path of file: ./repos/concurrent-ruby/lib/concurrent-ruby/concurrent/collection
    
    the code of the file until where you have to start completion: require 'concurrent/synchronization/lockable_object'

module Concurrent
  module Collection

    # A
    
      def duplicate_and_clear_observers
        synchronize do
          observers = @observers.dup
          @observers.clear
          observers
        end
      end