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 Spring in Action this week in the Spring 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: 19719
    
  20

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If i use a Collections.synchronizedList () i still need to synchronize that list.