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 Concurrency API 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 "Concurrency API" Watch "Concurrency API" New topic
Author

Concurrency API

Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
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
Sheriff

Joined: Sep 28, 2004
Posts: 16692
    
  19

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Thanks Henry for the response
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Concurrency API
 
Similar Threads
Portability implications for NIO
Performance 1.2 to 1.3
Reference variable
Shoud I get a null?
Urgent!!! Need help for java API