This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes If i use a Collections.synchronizedList ()  i still need to synchronize that list. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "If i use a Collections.synchronizedList ()  i still need to synchronize that list." Watch "If i use a Collections.synchronizedList ()  i still need to synchronize that list." New topic
Author

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

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
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.


If you want something you never had do something which you had never done
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: If i use a Collections.synchronizedList () i still need to synchronize that list.
 
Similar Threads
ConcurrentModificationException inside a synchronized method
Just finished my first java program :-) Can you please give me suggestions on making my code better?
Speed of Collections, etc
In what cases we would generally use a Vector class??
Problems with Multithreading and Collections