//In order to isolate the effects of synchronization, we make sure
//that the garbage collector doesn't interfere with the test. So
//we use a bunch of pre-allocated, pre-sized collections, and
//populate those collections with pre-existing objects. No objects
//will be created or released during the timing phase of the tests.
List[] l = {new Vector(CAPACITY), new Vector(CAPACITY),
new Vector(CAPACITY), new ArrayList(CAPACITY),
new ArrayList(CAPACITY), new ArrayList(CAPACITY),
Collections.synchronizedList(new ArrayList(CAPACITY)),
Collections.synchronizedList(new ArrayList(CAPACITY)),
Collections.synchronizedList(new ArrayList(CAPACITY))};
int REPEAT = (args.length > 0) ? Integer.parseInt(args[0]) : 100;
//Vary the order.
test(l[0], REPEAT, "Vector");
test(l[6], REPEAT, "sync ArrayList" );
test(l[3], REPEAT, "ArrayList");
test(l[1], REPEAT, "Vector");
test(l[4], REPEAT, "ArrayList");
test(l[7], REPEAT, "sync ArrayList" );
test(l[2], REPEAT, "Vector");
test(l[5], REPEAT, "ArrayList");
test(l[8], REPEAT, "sync ArrayList" );