Design Patterns Singleton Midterm

  1. getInstance
    clients access a Singleton instance solely through getInstance
  2. DCLP
    • Double Check Locking Pattern
    • 1.Check if it needs modification
    • 2.LockĀ 
    • 3.Check again
    • 4.If needs modification again - do so
    • 5.Unlock
  3. What happens if the thread switch occurs between the allocation and the initialization?
    the other thread could start using the singleton object before the initialization has completed.
  4. Compiler Memory Barriers
    • prevent compiler from reordering code
    • doesn't stop CPU from reordering
    • prior to 2005
  5. Hardware Memory Barriers
    • prevent CPU from reordering
    • combined with compiler memory barriers
    • since 2005, compiler/CPU barrier are used
  6. memory barriers
    used to force one process to complete its operation before another process can act on that variable
Author
djon
ID
263054
Card Set
Design Patterns Singleton Midterm
Description
midterm
Updated