This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If i use a Collections.synchronizedList () i still need to synchronize that list.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i use a Collections.synchronizedList () i still need to synchronize that list.


Then what is the use of using this method Collections.synchronizedList ()

Please suggest your ideas.
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a synchronizedList return value, all individual methods are synchronized. So you can make a single call to add, remove or get and be sure that that add / removal / retrieval is executed atomically. However, it does not make compound statements atomic. Adding two elements after each other is still not an atomic operation, and neither is iterating over it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic