1 Reply Latest reply: Jun 26, 2007 1:38 AM by 791266 RSS

    Collections class has synchronized methods

    807605
      Collections class has synchronized methods like synchronizedCollection,synchronizedSet,synchronizedList and so on that return a synchronized collection.
      a) What is a synchronized collection that is returned here? What does it mean its synchronized when we still have to use #b below?
      b) The collection returned by the above methods must again be accessed synchronously within a synchronized block, Does using Vector avoid this?
      Please advice.
      Thanks
      Deepak
        • 1. Re: Collections class has synchronized methods
          791266
          a) What is a synchronized collection that is returned
          here?
          What? Those methods returns a wrapper that is synchronized. The wrapper delegates the calls to the original collection (but does so from synchronized methods)
          What does it mean its synchronized when we
          still have to use #b below?
          Why do you have to use b? Who says that?
          b) The collection returned by the above methods must
          again be accessed synchronously within a synchronized
          block,
          Who says so?
          Does using Vector avoid this?
          No