title: List of Active Objects
body: <p>I am trying to do something like below.</p>
  
  <p>Class A - It is a Class having static member variables and also it extends from the thread Class. It has a static arraylist of Class B objects.</p>
  
  <p>Class B - Just a Class whose objects need to register to class A, on registration the thread from Class A would call certain methods of the objects continuously at some interval.</p>
  
  <pre><code>class A extends Thread
  {
      private static A a;
      private static ArrayList objsClassB;
      void run()
      {
        /* infinitely iterate through the objsClassB objects and call certain methods..
           in try and catch */
      }
  
      public static void StartEmulating() {
          if(a == null)
          {
              a = new A();
              a.start();
          }
      }   
      public static void registerToA(B m1)
      {
         objsClassB.add(m1);
      }
  
  }
  
  class B
  {
     B()
     {
       registerToA(this);
     }
  }
  public static void main(String[] args)
  {
     A.StartEmulating();
     B b1 = new B();
     B b2 = new B();
     //make b2 = null to simulate object deletion...
     b2 = null;
  }
  </code></pre>
  
  <p>Now, what i want to do is that if due to some reason b2 got deleted(i.e. lets say the thread in which it was created got crashed) i want to deregister that from the list but that is not happening.
  Is there a way for me to store the b2 in the list ?</p>