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:
committed by
KevinGilmore
parent
48b2316187
commit
53d22bebbc
+18
@@ -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());});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user