Created
September 27, 2016 09:51
-
-
Save hendrikebbers/c249f88e21600008bcb345467632bd8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final List<String> baseList = new ArrayList<>(); | |
final List<String> unmodifiableList = Collections.unmodifiableList(baseList); | |
Executors.newSingleThreadExecutor().execute(() -> { | |
while(true) { | |
baseList.add(UUID.randomUUID().toString()); | |
try { | |
Thread.sleep(10); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
try { | |
Thread.sleep(100); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
for(String s : unmodifiableList) { | |
System.out.println("Val: " + s); | |
try { | |
Thread.sleep(5); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment