Summary: Basic Design Principles for Synchronization


  • Avoid it. Introduce synchronization only when necessary.

  • Isolate it. Cluster synchronization needs into a single-responsibility class that does as little as possible. Ensure that as few clients as possible interact with a synchronized class. Ensure that as few methods as possible interact with shared data.

  • Shared, or "server," classes should provide synchronization instead of depending on clients to synchronize properly.

  • If a server class has not provided synchronization, consider writing a "wrapper" class that adds synchronization and delegates all messages to the server class.

  • Use the synchronization class library located in java.util.concurrent.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net