The JAX-WS web service itself is Singleton. This means that the entire request will be processed using one instance of the web service (for example, a servlet).
Thus, any member of the class will be "shared" between all requests. In your case, you do not need to set your members (i.e. couponMap) static attributes.
Conclusion: don't worry, all your threads (request) will access the same "couponMap". Since you no longer need getCouponMapCreationTime , I think you can eliminate the SingletonMap abstraction and use the map directly in your web services class.
But I have something very important to add. If several threads (request) will access your card, you must make it thread safe !!! There are many ways to do this, but I will give an idea: use ConcurrentHashMap instead of HashMap . This will make all your get(), put(), remove() operations thread safe! If you need a wider scope, you can use synchronized blocks, but please avoid synchronizing methods because the scoop is too large and always synchronizes with the this object.
source share