aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
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: 19557
    
  16

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: If i use a Collections.synchronizedList () i still need to synchronize that list.
 
Similar Threads
Speed of Collections, etc
Problems with Multithreading and Collections
Just finished my first java program :-) Can you please give me suggestions on making my code better?
ConcurrentModificationException inside a synchronized method
In what cases we would generally use a Vector class??