-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Caching and thread safety
PostPosted: Tue Sep 30, 2008 7:14 pm 
Newbie

Joined: Tue Sep 30, 2008 7:10 pm
Posts: 1
Hello,

I apologize if this is the wrong forum for this question. My scenario is this: I have a simulation engine that loads a large number of objects (~100,000) int List<T> collections.

The simulation fires off several threads. One of which iterates through a number of the objects updating their state. This happen once every minute. There is also a ThreadPool that is handling state changes coming in from WebService calls. Another thread is fired off every fifteen minutes to save all updated objects back to the database.

Needless to say, because collections are not thread-safe, I am getting errors that the collection has changed while enumerating it. My concern is that if I implement locking, I will end up waiting a long time for the threads to finish. This does not seem optimal. Scalability and performance are very important.

Another idea is to copy the collection into another array and save that array. The update thread can continue to process while the duplicate array is saved. This also seems cumbersome and a hack.

I guess what I am looking for is a cache layer that can track changes and update the database periodically.

How can nHibernate help with this?

Thanks,

Rick


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.