How to know if a Component in vaadin is disposed?

I have a timer with Component A, like this:

       scheduler = Executors.newSingleThreadScheduledExecutor();
       scheduler.scheduleAtFixedRate(new Loader( this ), 0, 1, TimeUnit.SECONDS);

I want to shutdown the timer when the Component A is disposed.

Best regards

Maybe you can simply check wether it is null or not?

Depends on what he means with disposed.
When you mean:

  1. not attached to a UI anymore: you can check when the Component.detach / DetachListener is called
  2. when the variable is set to null: you can just check if(componentA == null)
  3. the point when the actual Object in the Stack is removed by the Java Garbage collector: Not really possible to check or at least quite complicated and impractible.

Thank you all.
The DetachListener works fine.