Published Sep 3, 2019

Episode 19: Concurrency Pt. 2

Explore the intricacies of concurrency with Alexander von Zitzewitz and Michael Scharf as they delve into thread management, concurrency patterns, and architectural considerations, revealing how these techniques can optimize system efficiency and reshape software design.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Singletons

    and explore the intricacies of singletons and the double-check locking pattern, particularly in Java. Michael highlights the potential pitfalls of using singletons, noting that they can erode architecture and are akin to global variables 1. He explains that while double-check locking can optimize resource acquisition, it is problematic in Java due to the language's bytecode and virtual machine design 2. Alexander warns against using double-check locking in Java, as it can lead to unpredictable behavior 1.

    Please don't use double check locking in Java because it will not work.

    ---

    The discussion underscores the importance of understanding language-specific constraints when implementing concurrency patterns.

       

    Active Objects

    Active objects play a crucial role in concurrent programming by encapsulating threads and managing asynchronous computations. describes how active objects use input queues protected by locks to handle multiple computation requests simultaneously 3. This pattern allows active objects to remain reactive while processing previous inputs, making them suitable for worker threads that perform asynchronous tasks. However, Michael cautions that queues can introduce jitter in real-time systems, suggesting architects minimize their use in critical paths 3.

    Active objects have typically an input queue, which is of course protected by a log.

    ---

    The design of active objects highlights the balance between responsiveness and resource management in concurrent systems.

       

    Synchronization

    Synchronization is essential in concurrent programming to manage access to shared resources. explains the use of locks and monitor objects to protect shared data, emphasizing the importance of careful lock management to avoid deadlocks 4. He notes that while monitor objects simplify synchronization in Java, they can be cumbersome and error-prone if not handled correctly. Michael adds that reactive design patterns, such as the reactor pattern, can achieve high performance without the overhead of concurrency in single CPU systems 4.

    Always beware of the overhead associated with concurrency.

    ---

    These techniques illustrate the trade-offs between simplicity and complexity in designing concurrent applications.

Related Episodes