Every Friday we will post the latest and greatest articles, blog pots etc. from Java Champions. Enjoy!
Dr Heinz M. Kabutz Contribution -
java.util.Optional - Short Tutorial By Example - Abstract: Java 8 introduced the java.util.Optional class, based on the famous Guava class by the same name. It was said that we should hardly ever call get(). In this newsletter we offer a short tutorial that demonstrates coding examples of alternatives to get().
Sorting Lists - Abstract: List has a new method sort(Comparator). This is handy, as it allows implementations to specialize how to sort their internal data structures. Vector only synchronizes once per list, not once per element. ArrayList avoids copying the array unnecessarily. CopyOnWriteArrayList works.
Concurrency Puzzle - System.arraycopy() - Abstract: "Friends don't let friends write low-level concurrency by themselves."
Concurrency Puzzle Helpful Hints - Abstract: In the previous newsletter, we sent out a threading puzzle for you to solve. Here are some hints to help you figure out what is going on.
Concurrency Puzzle Explained, Solved With StampedLock - Most programmers had a blind spot with the statement "arr[size++] = e;" We somehow think that size will be updated after the assignment. In this newsletter we look at this basic concurrency bug and also present a solution in the form of the Java 8 StampedLock.