11 Replies Latest reply: Sep 22, 2006 8:06 AM by 791266 RSS

    Sharing a data Structure(HashMap) across multiple threads

    807569
      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:
      HashMap info = new HashMap();
      File[] contents = mainDir.listFiles();
      
      for (int i = 0; i < contents.length; i++) {           
                          spawnThread st = new spawnThread(contents, info);
      Thread t = new Thread(st);
      t.start();
      }

      How can I get it done properly?