From the course: Java EE: Design Patterns and Architecture

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Singleton pattern concurrency

Singleton pattern concurrency

From the course: Java EE: Design Patterns and Architecture

Start my 1-month free trial

Singleton pattern concurrency

- [Instructor] So already we have seen how the Java EE implementation of the singleton pattern is substantially different to its classical implementation. And requires substantially less code to achieve the same, or better, results. We have been given more control over when the bean is instantiated, either at application startup or on first use. We can specify a method to execute after the bean has been instantiated, that perform startup tasks, and we can specify its dependency on successful instantiation of another bean. These new features enhance the behavior and performance of the singleton bean substantially. But we can go further. Remember that I mentioned that the singleton bean is thread-safe by default, as concurrency is managed by the container. Well Java EE offers two types of concurrency management. Container-managed concurrency, and bean-managed concurrency. By default the container manages the concurrency, removing the need to implement the usual concurrency solutions…

Contents