I am developing a program where I have multiple threads accessing a Map stored in the class Problem.
This map, for the "value", contains an object (Slot) containing a name and a List of instances of Car.
So, my question is:
Since the first map, accessed by different threads, is thread-safe, will I need a thread safe list for the list inside Slot or am I safe with an ArrayList?
Please note that Car is an AtomicReference and is the critical area where I use compareAndSet() on.
public class Problem {
ConcurrentSkipListMap<Integer, Slot> slots;
//...
}
public class Slot {
private String name;
List<AtomicReference<Car>> cars; // does this need to be a thread safe list?
//...
}
public class Car {
//...
}
A simple diagram that shows the problem:
Thank you.
