in your case - as you are swapping out the RuleBase - I woudl suggest locking or syncing things when swapping - not sure how to do that given that spring is in control.<br><br>Also, i would suggest you use RuleBase#newWorkingMemory(false) so that it doesn't keep a weakhashmap around pointint back to the working memories, as you don't need it (it will mean less big GC pauses under heavy load in your case).
<br><br>Michael.<br><br><div><span class="gmail_quote">On 3/13/07, <b class="gmail_sendername">jdepaul</b> <<a href="mailto:jjdepaul@us.ibm.com">jjdepaul@us.ibm.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>I know the threading topic has been discussed quite extensively, but I still<br>need some guidance in the following case:<br><br>My application has a RuleManager object that maintains references to many<br>RuleBase objects in a HashMap. I'm using Spring Framework to wire the bean
<br>relationships together.<br><br>The RulesManager is typically busy servicing client requests for instances<br>of WorkingMemory objects which it fetches from the individual RuleBase<br>objects it maintains in its Hash (
wm.newWorkingMemory() ).<br><br>>From time to time, I'll need RulesManager to reaload the rules that are<br>associated with the individual RuleBase object - for that, I'm going to<br>create a new instance of the RuleBase object and then I need an efficient
<br>and safe way to 'swap' this new RuleBase object for the old object reference<br>in the RulesManager's map.<br><br>My question is: should I synchronize the getWorkingMemory(..) method inside<br>my RulesManager object that uses the hashmap, AND also synchronize the code
<br>that does the object swap - would that be sufficient?! How would I do it<br>using Collections.synchronizedMap() - remember that I don't have that much<br>control over the creation of the Map since Spring controls that part of
<br>populating hashmap at startup.<br><br>The critical factors for me are speed and efficiency in servicing regular<br>client requests for WorkingMemory - ideally, I'd synchronize only the method<br>that does the object swap, but I'm sure that may have some bad
<br>consequences... though as long as I can avoid the race condition I could<br>probably live with it.<br><br>Thanks in advance for ideas -<br>--<br>View this message in context: <a href="http://www.nabble.com/Question-on-data-safety-and-threading...-tf3396050.html#a9454823">
http://www.nabble.com/Question-on-data-safety-and-threading...-tf3396050.html#a9454823</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>_______________________________________________
<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br></blockquote></div><br>