Using container managed concurrency

Concurrent access to a singleton EJB is by default controlled by the container. Both read and write access to a singleton is limited to one client at a time. However, it is possible to provide a finer level of concurrency control through the use of annotations. In this recipe we will examine how this is done.

Getting ready

The steps used to incorporate container managed concurrency involve:

  1. Specify the currency approach using the @ConcurrencyManagement annotation
  2. Annotate each method with the @Lock annotation

    The concurrency management approach used by an EJB is specified using the @ConcurrencyManagement annotation. Its argument determines whether concurrency management is maintained by the container, or as we will ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.