Java SE Concurrency - Low-Level

Print the objectives

Take the exam   Take a beta test

Java is one of the few languages designed from inception to support concurrency without the requirement for additional libraries. Tools for the management of concurrent programming have been available from the very first releases of the language, providing both syntactic and API support.

Until the release of Java 1.5, these tools have been powerful but granular, a developer having the facilities to synchronize on monitors at a class, instance and nominated Object level, combined with the functionality provided by Object, Thread, ThreadGroup and ThreadLocal classes.

With the advent these packages in the Java 1.5 release:
  • java.util.concurrent
  • java.util.concurrent.atomic
  • java.util.concurrent.locks
A whole host of extended facilities have been added to the Java API allowing far finer grained control over concurrent programming tasks.

This examination will seek to test the examinee's knowledge of the deeper concepts of concurrent programming, and more detailed aspects of the new Java 1.5 API additions.

Not covered: Everything covered in the Java SE Concurrency - High-Level exam.
  Released  Beta  Frozen  

Concepts & Terminology

 
 

Terminology  3 questions

Explain the following common concurrency terms and the concepts they define:
  • Producer & Consumer
  • Race Condition
  • Deadlock & Livelock
  • Starvation
  • Lock
  • Condition
  • Mutex
  • Fairness
6 79 10

Behaviours  1 question

Detail the distinctions between the following concepts
  • Weakly consistent traversal and Fast-fail traversal
3 12 8

The Java Memory Model

Be able to demonstrate understanding of the Java Memory Model guarantees, and the impact of both optimising and adaptive compilers (such as the Sun HotSpot JVM) on the model
 
 

The volatile keyword  2 questions

  • Show that volatile fields cannot be cached in processor registers.
  • Describe how a Java compiler will not create byte-code that performs out-of-order write operations on volatile fields.
  • Demonstrate that the primitive increment/decrement syntax (++/--) is not atomic for volatile fields.
3 21 9

Guarantees regarding updates outside synchronized blocks  2 questions

  • Demonstrate understanding of the fact that non-volatile fields can be cached outside main memory
  • Demonstrate that unsynchronized access via multiple threads can cause inconsistent reads and hence update corruption.
7 7 6

Granularity of 32 bit updates  1 question

  • Show knowledge that the JVM guarantees a maximum of only 32 bit update atomicity.
  • Show that 64 bit data types (long, double) can be in an inconsistent state between the two 32 bit atomic updates required to update their 64 bits.
2 10 7

Double checked locking  1 question

  • Identify code using lazy singleton instantiation via DCL, be able to identify its points of failure.
  • Be able to correct DCL code using:
    • Synchronization of the instantiating method, or,
    • Instantiation during static initialization.
    • volatile keyword with Java 5 or higher
2 14 4

Collections

Understand some of the less frequently used concurrent extensions to the collections interfaces/implementations
 
 

CopyOnWrite  2 questions

Usage of CopyOnWriteArrayList and CopyOnWriteArraySet
  • Anticipate the high costs of modification
  • High memory cost for Iterator instances
  • Identify ideal usage situation requiring frequent simultaneous reads and infrequent writes.
5 20 4

BlockingQueue  2 questions

BlockingQueue implementations, and their distinguishing characteristics:
  • SynchronousQueue
    • Show understanding that a SynchronousQueue will never contain an element
    • Be able to show a SynchronousQueue performing an "hand off" between threads
  • DelayQueue
    • Demonstrate that a DelayQueue will block on a take request when elements await delay expiry.
3 22 6

Synchronizers

Understand more complex two of the four new synchronizer implementations and how to use them
 
 

CyclicBarrier  2 questions

CyclicBarrier usage
  • Distinguish the multi usage CyclicBarrier behaviour from one shot usage of CountDownLatch
  • Show correct usage of constructors, and know what the parameter parties defines.
  • Design code to execute at barrier breakage, controlled by the CyclicBarrier itself, using the CyclicBarrier(int, Runnable) constructor.
  • Describe the behaviour of the await() methods, leading to eventual barrier breakage.
  • Identify the methods used to query the number of threads awaiting barrier breakage, and the number further parties required to break the barrier. (getNumberWaiting() and getParties().)
  • Write code to correctly reset a barrier using the reset() method.
0 29 3

Exchanger  2 questions

Exchanger usage
  • Demonstrate the Exchanger mechanism being used to move objects back and forth between a producer and consumer pair.
  • Define typical exchange() behavior, when not interrupted.
  • Define exchange() behavior when interrupted.
1 12 4

Atomic Classes

Display comprehension of the atomic classes.
 
 

Basic atomic value classes  3 questions

Basic atomic value classes (AtomicInteger, AtomicLong, AtomicReference and AtomicBoolean).
  • Display knowledge of the distinction between the atomic version and the equivalent primitive type.
  • Differentiate the standard Java numeric assignment operators (x++, ++x, x += y, etc.) from their atomic counterparts getAndIncrement(), incrementAndGet(), getAndAdd(), etc.).
  • Understand the behaviour of both the compareAndSet() and the getAndSet() methods.
  • Write code to use an instance of AtomicInteger to model an atomic numeric type not directly supported such as double or float.
  • Contrast the behaviour with a volatile member's behaviour.
  • NOTE: weakCompareAndSet() is not covered.
2 33 14

Advanced atomic value classes  1 question

Advanced atomic value classes AtomicStampedReference and AtomicMarkableReference. Communicate the knowledge of using these less frequently used classes to detect values which may have been updated while still retaining their original value.
0 9 5

Locks

Demonstrate knowledge of the locking facilities
 
 

ReentrantLock  2 questions

ReentrantLock usage
  • Show knowledge of Thread ownership of a ReentrantLock, and multiple "holds" on the lock.
  • Demonstrate usage of lock() and lockInterruptibly()
  • Demonstrate usage of unlock() and know when IllegalMonitorStateException will be thrown when calling it.
  • Show knowledge of tryLock()'s exemption from the fairness parameter used to construct an instance of ReentrantLock.
1 21 8

ReentrantReadWriteLock  1 question

ReentrantReadWriteLock usage
  • Demonstrate that read locks cannot be acquired until all write locks on a writing thread have been released.
  • Show that write locks can be downgraded to read locks but not vice-versa.
  • Explain lock ownership:
    • Read locks are not owned by a Thread, while,
    • Write locks are owned by a Thread.
1 18 3

Exam information

  • 37 minutes
  • 25 questions (434)
  • 80% required
  • +3 √
  • - 12  points
  • 15 day delay
  • status: released

Exam leader