[concurrency-interest] question on concurrent HashMap

Amarnath Nanduri amar_nan at yahoo.com
Thu Nov 2 11:02:14 EST 2006


I am currently using a concurrent hashmap to act as shared memory between different threads. I think I might be doing something wrong and would appreciate your help and guidance on this.
   
  The scenario is:
  A manager class fires up a bunch of database objects (implementing the Callable interface)  every one minute (in a Timer task) and gets back the immutable data objects. 
  //sample code
  ExecutorService.invokeAll(database objects implementing Callable interface).
   
  The manager then updates a concurrent HashMap with these data objects. 
   
  The gui components request the manager for the concurrent HashMap and each gui component asks for its own data object out of the cncurrent hash map. All gui components are in a single swing timer that fires up an event once every minute and asks the gui components to get their data objects. 
   
  Both Timer Task and Swing Timer are fired every one minute. I currently guess the amount of time delay I need (set to 30 seconds)  (to get the data from the database and populate the concurrent hash map) before the swing timer fires an event for the gui components to fetch from the concurrent hash map.
   
  I have a feeling that I am doing something wrong here, but can't pinpoint the exact cause. One question that bothers me is that how can I make the Timer Task (in manager) and Swing Timer (controlling the gui components) be in step. i.e only after the concurrent hashmap is populated by the manager, do I want the swing timer firing up to allow the gui components to get their data.
   
  Is there a way for the gui components to wait till their data object is put in the concurrent hash map, before they attempt to retreive the data from the concurrent hashmap?
   
  Thank you for your time and patience.
   
  Regards,
  Amar..

 	
---------------------------------
Everyone is raving about the  all-new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061102/57bf0974/attachment.html 


More information about the Concurrency-interest mailing list