Lecture 3: Concurrency Abstractions

Further concurrency mechanisms provided in Java. Data abstraction: ensuring consistency by using library classes for atomic actions or thread-safe datatypes such as concurrent collections. Why these are still not enough. Control abstractions: fine-grained parallelism by decomposing processes into threads, then threads into tasks. Executors in Java. Callables and futures.

At the start we had a quick recap on Amdahl’s law and I showed the simple way it is derived (see the Wikipedia page). This motivates the design of language features which allow as much concurrency as possible, while maintaining correctness! We ran out of time to cover the control abstractions, I will spend a bit of time in the next lecture covering these, but you should read the slides for the homework.

Link: Slides.


You should explore Java concurrency mechanisms in more detail, in particular, using some of the facilities provided by the java.util.concurrent packages.

  • Experiment with a program that exhibits a race condition, and make sure you can fix it in the ways described in the lecture slides.
  • Read the slides on control abstractions and write a version of the Pigeon Fancier program which uses the executor framework and allows for dynamic reconfiguration of the pigeon coop.
  • Investigate some of the explicit locking facilities provided in java.util.concurrent and make sure you can explain situations when these might be needed.

See the lecture slides for more detail. Please post questions and discussion here and we’ll follow up.

A plea. do please at least try the homeworks we are giving. We are trying to give interesting exercises and and help you structure some of the study time you need to spend for the course.

2 Responses to Lecture 3: Concurrency Abstractions

  1. s0803652 says:

    The wikipedia page link is broken, it has one ‘http://’ too many.