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.
The steps used to incorporate container managed concurrency involve:
- Specify the currency approach using the @ConcurrencyManagement annotation
- 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 ...