permaculture playing cards*
The moose likes Threads and Synchronization and the fly likes Infinaite Loop on Cached collection in Multi threaded environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Infinaite Loop on Cached collection in Multi threaded environment" Watch "Infinaite Loop on Cached collection in Multi threaded environment" New topic
Author

Infinaite Loop on Cached collection in Multi threaded environment

Rasika Abey
Greenhorn

Joined: Sep 09, 2011
Posts: 1
My application is running on tomcat with Spring and Hibernate framework. It use EHCache as a cache provider in service level. That means objects created by service classes put in to the cache. (Not hibernate Dao objects).

There are some collection objects (HashSet, ArrayList, HashMap) in these cached objects. Non of them are syncronized collections. All are not thread safe, but not modify by the application after put in to the cache.

I found infinite loop in many ocations when I loop through this collection. Some of the loops are Iterator loops and some others are old for loops run base on int index.

I mannaged to overcome one infinite loop by replasing a HashSet with Collections.synchronizedSet(new HashSet()). But I don't understand the real problem of using normal HashSet as it's never being modified by the application. (Does EHCache modify them?)

Please explain me if there are any concerns here using non-thread safe collections.
 
 
subject: Infinaite Loop on Cached collection in Multi threaded environment
 
Similar Threads
Hibernate caching- Which caching to use for performance ?
Detecting Crashes in JBoss 4.0.2
Hibernate query cache issue
Hibernate : preventing large dataloads without lazy loading
Caching implementation strategy