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

Concurrency API

 
Anselm Paulinus
Ranch Hand
Posts: 390
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During the course of learning the new API; I undestood that the new java.util.CopyOnWriteArrayList creates a new copy of the underlying array for writing thereby disposing off synchronization. My question is how does this affect memory management in a situation where there are many concurrent writes to be done; I guess it is going to create this many copies of the arrays and have them stored in memory; this I think is akin to having too many objects in a servlet session. Please correct me if I am wrong.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the CopyOnWriteArrayList only makes a copy to avoid stepping on an iterator. And once you make a copy, that iterator is safe from future writes. So the only scenario where lots of copies are made, is when you are getting lots of iterators while making lots of calls to mutable methods.

Henry
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry for the response
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic