Why the size of hashmap is different then using threads?
<blockquote>
  <p>I have a problem with run the program. At one execution the list(HashMap) has a size and at another execution the HashMap product has different size. 
  Below is the code of method in which I created the pool of thread...</p>
</blockquote>

<pre><code>public HashMap&lt;Integer, MatrixIndex&gt; getMultiplyMatrix(HashMap&lt;Integer, MatrixIndex&gt; rowsMap, HashMap&lt;Integer, MatrixIndex&gt; colsMap,
        int noThreads) throws InterruptedException {
    HashMap&lt;Integer, MatrixIndex&gt; product = new HashMap&lt;Integer, MatrixIndex&gt;();
    ExecutorService pool = Executors.newFixedThreadPool(noThreads);
    for (int i = 0; i &lt; rowsMap.size(); i++) {
        pool.submit(new MultiplyMatrix(rowsMap, colsMap, product, i));
    }

    pool.shutdown();
    pool.awaitTermination(1, TimeUnit.DAYS);

    return product;
}
</code></pre>

<p><strong>The method run() is</strong> </p>

<pre><code>public void run() {

        Map&lt;Integer, Double&gt; mapRow = rowsMap.get(row).getMap();
        MatrixIndex s = new MatrixIndex();
        for (int j = 0; j &lt; columnsMap.size(); j++) {
            Map&lt;Integer, Double&gt; mapCol = columnsMap.get(j).getMap();
            double sum = 0.0;
            for (Map.Entry&lt;Integer, Double&gt; entry : mapCol.entrySet()) {
                int val = entry.getKey();
                if (mapRow.containsKey(val)) {
                    sum += mapRow.get(val).doubleValue() * entry.getValue();
                }
            }

            s.add(j, sum);

        }
        product.put(row, s);
    }
}
</code></pre>

<p>And i call product = p.getMultiplyMatrix(rowsMap,columnsMap, 4);
product.size() is different if I run several times the program.
<strong>Is a problem with synchronize threads?? Thanks</strong></p>