import java.util.List; import java.util.Collections; import java.util.ArrayList; public class ListGetLast { // You must use synchronization (uncomment below) // to ensure these methods are atomic, even if the original // list is thread-safe. Running without synchronization is likely // to produce an indexoutofbounds exception public static Object getLast (List l) { /* synchronized (l) { */ int lastIndex = l.size() - 1; return (l.get(lastIndex)); /* } */ } public static Object deleteLast (List l) { /* synchronized (l) { */ int lastIndex = l.size() - 1; return (l.remove(lastIndex)); /* } */ } public static void main(String args[]) { final int n = 10000; final List list = Collections.synchronizedList(new ArrayList ()); for (int i = 0; i