I want to write a Thread-safe method sum() but I'm not sure if I can use two AtomicIntegers to make it safe or do I have to use a synchronized block?
class A {
private AtomicInteger a = new AtomicInteger();
private AtomicInteger b = new AtomicInteger();
public void sum(int c) {
a.set(a.get() + b.get() + c);
}
}