Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Infinaite Loop on Cached collection in Multi threaded environment

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic