View RSS Feed

Design Patterns

Design patterns in Java.

  1. Lazy instantiation using double locking mechanism

    by , 03-09-2012 at 07:45 PM
    The standard implementation is a thread-safe implementation. However, it is not the best implementation as when you talk about performance, the synchronization is quite expensive.When the object gets initialized, there is no need to check the synchronized method getInstance for synchronization. When singleton object has already been created, just return it without making use of synchronized block.

    When for the first time getInstance() method is called, singleton instance is created. ...