Given the interface:
Public interface Idgenerator {
int getNextId();
}
Which class implements IdGenerator in a thread-safe manner, so that no threads can get a duplicate id value current access?
Given:
ConcurrentMap PartList = new ConcurrentMap<>();
Which fragment puts a key/value pair in partList without the responsibility of overwriting an existing key?
Given:
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicCounter {
private AtomicInteger c = new AtomicInteger(0);
public void increment() {
// insert code here
}
}
Which line of code, inserted inside the increment () method, will increment the value of c?