Pages

Tuesday, October 29, 2013

Handling collections in java

Recently I was wondering about how java handles collections and the existing opensource java libraries to handle this scenario. Common alternatives to java collections framework are
  1. Apache commons
  2. Guava
  3. PCJ
  4. Trove
Number 1 and 2 alternatives are more popular among developers while 3 and 4 are not mentioned frequently (They are for primitives).  3 and 4 provide more performance compared to Java collections framework. Guava can be used in most cases while it seems like using this library is bit complex but at the same time it reduces many bottlenecks present in the collections operations.

Having mentioned all these libraries, one should also note that if your app does not demand handling complex collection operation, lots of data to be stored in a collection, java collections framework itself is more than adequate.

Below is a nice article that analyze the above topic in detail

http://stackoverflow.com/questions/629804/what-is-the-most-efficient-java-collections-library


Monday, October 21, 2013

java thread pool example

Do you have multiple jobs to execute using a pool of threads and need to know how to do it gracefully? See the link below to know how it can be done using executors and thread pool executors.

http://www.javacodegeeks.com//2013/01/java-thread-pool-example-using-executors-and-threadpoolexecutor.html