**Introduction**   

I am having some difficulties with figuring out what's causing me to get a NullPointerException in a HashMap that should be fairly simple. To understand why I am using a HashMap I think the best way to describe it is to say that I have a Multithreaded program which has some results I would like to store. In that context I have created a class called `SaveMethod` which will be used to store values from the process. Since one never knows which thread that will finish first I use a `HashMap` to store thread `i`'s value in this hashmap as follows:

**Code:**   

First the definition of the HashMap:

```
// The first Integer element is the thread index, the second is the Double value
private static HashMap<Integer,Double> AUC = new HashMap<Integer,Double>();

```

Then I call this method ones a thread terminates for storage:

```
public static void setAUC(double AUC,int i){        
    Double AUCtemp = AUC;
    SaveMethod.AUC.put(i,AUCtemp);
}

```

**Some more description:**   

Now, I have previously had success implementing above functionality by the usage of:

```
private static HashMap<Integer,Double[]> AUC = new HashMap<Integer,Double[]>();

```

That is, compared to the previous example, `Double[]` instead of `Double`. And that has worked pretty well.

**Question**   

My question is twofold: 1)
Why am I getting `Exception in thread "main" java.lang.NullPointerException` when I try to call this code:

```
    public static Double getAUC(int i){
        double AUC = SaveMethod.AUC.get(i);
        return AUC;
    }

```

2) is this saving option thread safe?

**Some additional reasoning why I need this:**   

let me try and justify why I need this storage option. I have a set of calculations that need to be performed, lets say 100. Each calculation takes approximately 10 seconds. Now, to reduce computational time I have implemented Multithread so that these calculations can be done simultanously. But these calculations does not depend on each other in any way. However, I need to store each result from each thread (which is a lot of different values/matrixes etc.) for each computation, so that the results can be reached globally from other methods/classes for plotting purpose. What do you recon is the way to store the results from the calculation AND maintain a thread-safe enviroment?