Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 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
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!