I have a requirement to maintain state in memory within a web application. The state needs to be shared among HTTP sessions. Although this can be done using a singleton, thread safety is a major concern. What is the best course of action to use the singleton for maintaining state across sessions but also ensure thread safety? I suppose making each method synchronized that alters state of the singleton will accomplish what I need. Or are there issues there as well? Thanks.
Login or Sign Up
- Log in with