Updates:
Summary: Scopes.SINGLETON uses a global lock
Comment #4 on issue 183 by limpbizkit: Scopes.SINGLETON uses a global lock
http://code.google.com/p/google-guice/issues/detail?id=183
This also impacts single injectors. I think the best policy is to avoid
creating threads inside Providers,
@Provides methods and injected members.
public void testSingletonScope() {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override protected void configure() {}
@Provides @Singleton Long provideTwo(final Provider<Integer>
oneProvider) throws Exception {
return Executors.newSingleThreadExecutor().submit(new
Callable<Integer>() {
public Integer call() throws Exception {
return oneProvider.get();
}
}).get() + 1L;
}
@Singleton @Provides Integer provideOne() throws ExecutionException,
InterruptedException {
return 1;
}
});
injector.getInstance(Long.class);
}
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---