BAEL-2287 - An Introduction to Synchronized Java Collections (#5385)

* Initial Commit

* Add pom.xml

* Update pom.xml

* Update pom.xml

* Update SynchronizedSortedMapUnitTest.java
This commit is contained in:
Alejandro Gervasio
2018-10-10 00:20:23 -03:00
committed by KevinGilmore
parent 48b2316187
commit 53d22bebbc
8 changed files with 293 additions and 90 deletions
@@ -0,0 +1,18 @@
package com.baeldung.synchronizedcollections.application;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
public class Application {
private static final Logger LOGGER = Logger.getLogger(Application.class.getName());
public static void main(String[] args) throws InterruptedException {
List<Integer> syncCollection = Collections.synchronizedList(Arrays.asList(1, 2, 3, 4, 5, 6));
synchronized (syncCollection) {
syncCollection.forEach((e) -> {LOGGER.info(e.toString());});
}
}
}