On Sun, Dec 14, 2008 at 4:32 PM, Pablo Ruggia <[email protected]> wrote:
> I mean, if I have a singleton that is lazy initialized, for example, using > a Provider, does it get synchronized so only one instance is being created > at a time. Yes, Guice's singleton scope uses DCL with a global lock on Injector.class (which is rather conservative). If it's not a singleton, does it synchronize something anyway? This is typically up to the scope. Probably HTTP session scope synchronizes on the session, HTTP request probably does not synchronize because it uses ThreadLocal. Which is my responsibility as a library client in what regards to thread > safety. Once Guice returns from createInjector, thread safety is up to you. So if you have a provider that manages its own lazyy reference to something, it's up to you to make sure it is thread safe. The same goes for everything that is mutable. Singletons that keep mutable state need to be properly synchronized / volatile'd. Cheers Robbie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
