Difference between singleton and eagersingleton for Gin or Guice?
Asked Answered
T

1

9

I was wondering what is the different between singleton and eagersingleton for Gin or Guice?

Theater answered 2/5, 2013 at 15:50 Comment(0)
C
11

From Guice's Wiki

Eager singletons reveal initialization problems sooner, and ensure end-users get a consistent, snappy experience. Lazy singletons enable a faster edit-compile-run development cycle. Use the Stage enum to specify which strategy should be used.

  • Eager: "create an instance of this class when the Module is being run"
  • Lazy: "create an instance of this class when it's first requested for dependency injection"
Caddoan answered 2/5, 2013 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.