The Java Memory Model is a part of the Java Language Specification that
covers, among other topics, the effects of synchronization by means of
locks, the use of volatile and atomic variable, the guarantees given for
final fields. It has been around since the advent of Java and underwent
a major overhaul in release 5.0 of Java. Despite of its existence since
day one of Java it is an area of the language that many developers do not
feel comfortable with. It is considered guru knowledge and best ignored.
Avoidance, however, is no longer practical.
These days the prevalence of multicore processors requires that essentially
all Java applications must be multi-threaded if the want to take advantage
of the available cpu power. Inevitably many applications will make the
transition from a single-core architecture to a multi-core or multi-cpu
platform. This migration occasionally reveals (so far dormant) bugs
in the program: applications that worked properly and reliably in a single-core
context suddenly and inexplicably exhibit errors in a multi-core context.
Often this is due to the substantially more aggressive caching techniques
used on the processor level in combination with misconceptions regarding
the Java Memory Model on the programmer's side. In order to avoid
such misconeptions, the workshop discusses the Java Memory Model comprehensively
and in depth.
A proper understanding of the Java Memory Model does not only help tracking
down and fixing bugs. In addition, it allows development Java programs
with perceivably higher performance.
The elimination or at least reduction of sychronization is becoming
increasingly important in a multi-core and multi-processor world.
Using a multi-cpu platform users expect that an application should scale,
that is, its performance should increase with the number of available cpus.
This highly desirable effect does not occur automatically, but has to be
built into the application. Sequential, i.e., non-parallel, parts
of the program must be drastically reduced in order to utilize the multiple
cpus effectively. There are several technique for reduction of sequential
processing, among them the elimination of lock-based sychronization, but
also the use of atomic operations and programming techniques such as lock-free
programming.
The workshop discusses the Java Memory Model, the issues of visibilty
and reordering, the use of volatile and atomic variable, the implementation
of immutable types based on the memory model's initialization safety garantee,
and provides an introduction to the techniques of lock-free programming.
In this workshop, participants have the opportunity to practice and
apply the newly gained knowledge in hands-on labs. They will review
code, spot bugs, and fix them. In addition, they will use atomic
variables to eleminate lock-based synchronisation.
|
|
Prerequisite Courses
and Skills:
|
Working knowledge of Java and Java concurrency. |
|
Duration:
|
1 day |
|
Exercises:
|
Workshops and hands-on labs |
This is a course for Java programmers who want to round up their knowledge
of Java concurrency issues.
The course is designed to build on existing expertise as Java programmers
and aims to take the skills one step further. Prerequisite for the seminar
is sound knowledge of Java concurrency and substantial practical
experience with concurrent programming in Java.
OBJECTIVES
|
Know when to replace locks by volatile and atomics |
|
Understand the effects of locks, volatile, final and atomics |
|
Learn how to avoid subtle visibility bugs |
|
Understand the principles of lock-free programming |
The course is designed by Klaus Kreft & Angelika
Langer and backed by years of experience in teaching Java related
topics and more than a decade of real-world experience in industrial software
development in Java.
Angelika Langer is a freelance trainer/mentor
in the area of object-oriented software development in C++ and Java. She
is a recognized author and speaker at conferences worldwide and author
of the
Java Generics FAQ
.
Klaus Kreft is a senior consultant for more than
20 years and has served as the lead architect on several successful industry
projects. He develops in Java since 1995. He is a regular speaker at OO
conferences in Germany.
Together they are authors of the book "Standard
C++ IOStreams and Locales" and numerous articles on C++ and Java topics
in various computer magazines worldwide, including the column "Effective
Java" in the German JavaMagazin.
|