View Single Post
  #1 (permalink)  
Old September 22nd, 2006, 05:38 AM
ravishakya ravishakya is offline
Authorized User
 
Join Date: Dec 2005
Location: Kathmandu, Bagmati, Nepal.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sharing a data structure across multiple threads

Hi, I would like to share a data structure (e.g. HashMap) across multiple threads. Each thread will be adding an entry to the HashMap. A part of the code is:
Code:
HashMap info = new HashMap();
File[] contents = mainDir.listFiles();

for (int i = 0; i < contents.length; i++) {           
                    spawnThread st = new spawnThread(contents[i], info);
                                        Thread t = new Thread(st);
                    t.start();
 }


How can I get it done properly?


http://www.ravishakya.com
__________________
http://www.ravishakya.com
Reply With Quote