Using bean managed concurrency

While concurrency of a singleton is container managed by default, the developer can elect to manage the concurrency directly. The techniques used for this effort are illustrated in this recipe.

Getting ready

The steps used to incorporate bean managed concurrency involve:

  1. Specify the currency approach using the @ConcurrencyManagement annotation
  2. Designate critical methods with the Java synchronized keyword

    Critical methods are those methods which allow only a single thread at a time to use it.

How to do it...

We will reuse the ConcurrencyExample application developed in the previous recipe to illustrate bean-managed concurrency. In the EJB module add a singleton EJB to the packt package called SimulationBeanManaged. Use the ...

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.