Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Literally 100% of the Singleton locking we're talking about is taken from this interface and its javadoc is a great source of information. It's safe to imagine that under the covers the Singleton Container has an instance of ReadWriteLock which it uses to enforce the locking for all the Singleton bean's methods. Essentially:

  • @Lock(READ) == theSingletonReadWriteLock.readLock().lock()
  • @Lock(WRITE) == theSingletonReadWriteLock.writeLock().lock()

The EJB container may not use a ReadWriteLock but the semantics of a ReadWriteLock must be followed. Internally, we use an instance of java.util.concurrent.ReentrantReadWriteLock which supports correct memory synchronization, some reentrancy, lock downgrading, and more.

Startup and Startup Ordering

...