Hi there,
today I have noticed strange thing in my application. I have a class
MainFrame like this:

@Singleton
public class MainFrame extends JFrame implements Runnable {
  private final TaskBrowserCtr taskBrowserCtr;
  ...
  @Inject
  public MainFrame(TaskBrowserCtr taskBrowserCtr,...) {
    this.taskBrowserCtr = taskBrowserCtr;
    ...
  }
  ...
}

TaskBrowserCtr looks like this:

public class TaskBrowserCtr extends AbstractBrowserCtr {
  private final Timer timer = new Timer("TaskBrowserCtrTimer", true);
  ...
  @Inject
  public TaskBrowserCtr(...) {
    ...
   }
...
}

So, when TaskBrowserCtr gets injected into MainFrame, it creates new
TaskBrowserCtrTimer daemon thread.
Today I was debugging my application and I found there are two such
threads! So, I placed breakpoint inside TaskBrowserCtr constructor and
it was caught TWICE during Guice's Injector initialization
(Stage.PRODUCTION).

I have checked it very carefully: no other class in entire application
asks for TaskBrowserCtr. MainFrame is singleton and the only one who
asks for TaskBrowserCt... and there is only one injector, so how is
this possible that Guice calls constructor twice?

Thanks,
Witold Szczerba

--

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.


Reply via email to