import java.util.concurrent.locks.ReentrantLock;
public class MyList {
private List list = new ArrayList<>();
private ReentrantLock lock = new ReentrantLock();
public void add(Object obj) {
lock.lock();
try {
list.add(obj);
} finally {
lock.unlock();
}
}
}