Java 8 Concurrency Tutorial: Synchronization and Locks - Benjamin Winterberg
Welcome to the second part of my Java 8 Concurrency Tutorial out of a series of guides teaching multi-threaded programming in Java 8 with easily understood code examples. In the next 15 min you learn how to synchronize access to mutable shared variables via the synchronized keyword, locks and semaphores.
- Part 1: Threads and Executors
- Part 2: Synchronization and Locks
- Part 3: Atomic Variables and ConcurrentMap
The majority of concepts shown in this article also work in older versions of Java. However the code samples focus on Java 8 and make heavy use of lambda expressions and new concurrency features. If you're not yet familiar with lambdas I recommend reading my Java 8 Tutorial first.
For simplicity the code samples of this tutorial make use of the two helper methods sleep(seconds)
and stop(executor)
as defined here.
Read full article from Java 8 Concurrency Tutorial: Synchronization and Locks - Benjamin Winterberg
No comments:
Post a Comment