Monday, 19 August 2013

Java Synchronized Collections vs Object

Java Synchronized Collections vs Object

I'm wondering what the difference is between these ways of synchronization
List<Integer> intList = Collections.synchronizedList(new
ArrayList<Integer>());
synchronized (intList) {
//Stuff
}
and using an object lock
Object objectLock = new Object();
List<Integer> intList = new ArrayList<Integer>();
synchronized (objectLock) {
//Stuff
}

No comments:

Post a Comment