The Artima Developer Community
Sponsored Link

Java Answers Forum
ArrayList Performance

1 reply on 1 page. Most recent reply: Apr 8, 2003 6:08 AM by Adam Duffy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Sanjay

Posts: 6
Nickname: sanjay
Registered: Mar, 2002

ArrayList Performance Posted: Apr 1, 2003 3:01 AM
Reply to this message Reply
Advertisement
I am using ArrayList collection. I have two threads. One of the threads is inserting objects in the ArrayList(always appending) and another thread continuosly monitors the arraylist and gets objects from it at index 0. It also removes the object from ArrayList after getting the object. The thread inserting objects in ArrayList inserts at a very high speed around 13000 objects per second. A total of 2 Lakh objects are inserted into the ArrayList.

When I run this program it runs very well for sometimes and rate of insertion and removal of Objects from ArrayList is almost equal i.e. 13000 per second.But sometimes the processing slows down a lot in between from the end where the thread is getting the objects from ArrayList.The performance drops down to around 600 objets per second. This happens irregularly i.e sometimes program runs well and other times it slows down

Can anyone help?


Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: ArrayList Performance Posted: Apr 8, 2003 6:08 AM
Reply to this message Reply
Two possible solutions.

1. Use the ensureCapacity method of ArrayList.
2. Consider using the Observer/Observable object model, see http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html

Adam

Flat View: This topic has 1 reply on 1 page
Topic: appendreplace Previous Topic   Next Topic Topic: question about java.io

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use