👨‍💻
Software Engineering
Clean Code: Agile Software Craftsmanship
Clean Code: Agile Software Craftsmanship
  • Clean Code
  • 1: Clean Code
    • There Will Be Code
    • Bad Code
    • The Total Cost of Owning a Mess
    • Schools of Thought
    • We are Authors
    • The Boy Scout Rule
    • Prequel and Principles
    • Conclusion
  • 2: Meaningful Names
  • 3: Functions
  • 4: Comments
  • 5: Formatting
  • 6: Objects and Data Structures
  • 7: Error Handling
  • 8: Boundaries
  • 9: Unit tests
  • 10: Classes
  • 12: Emergence
  • 13: Concurrency
    • Why Concurrency?
    • Challenges
    • Concurrency Defense Principles
    • Know Your Library
    • Know Your Execution Models
    • Beware Dependencies between Synchronized Methods
    • Keep Synchronized Sections Small
    • Writing Correct Shut-Down Code is Hard
    • Testing Threaded Code
    • Conclusion
Powered by GitBook
On this page
  • Why Concurrency
  • Myths & Misconceptions
  • Concurrency always improves performance
  • Design does not change when writing concurrent programs
  • Understanding concurrency issues is not important when working with a container (Web or EJB)
  • Considerations when writing concurrent software
  1. 13: Concurrency

Why Concurrency?

Writing clean, concurrent programs is hard!

It's easy to write multi-threaded code that is fine on the surface but broken at a deeper level - code that works fine until the system is placed under stress.

Why Concurrency

  • Concurrency is a decoupling strategy. Decouple what gets done from when it gets done.

  • Decoupling what from when can dramatically improve throughput & structure of applications.

  • Offers powerful ways to separate concerns, making a system easier to understand.

Myths & Misconceptions

Concurrency always improves performance

Concurrency can sometimes improve performance, but only when there is a lot of wait time that can be shared between multiple threads or multiple processors.

Design does not change when writing concurrent programs

Decoupling what from when usually has a huge effect on the structure of a system.

Understanding concurrency issues is not important when working with a container (Web or EJB)

You need to know what your container is doing and how to guard against issues that comes with concurrent updates and deadlocks.

Considerations when writing concurrent software

  • Concurrency incurs some overhead, both in performance and additional code.

  • Correct concurrency is complex, even for simple programs.

  • Concurrency bugs aren't usually repeatable, so they are often ignored as one-offs.

  • Concurrency often requires are fundamental change in design strategy.

Previous13: ConcurrencyNextChallenges

Last updated 9 months ago