public class Person 
{ 
   public void increaseReferenceCount() { ... } 
   public void decreaseReferenceCount() { ... } 
   public int getReferenceCount(); 
   ... 
   public void doInit(String name, Date dateOfBirth, ... ) { ... } 
   ... 
} 

public class PersonPool 
{ 
   public static final int POOL_SIZE = 30; 
   protected static Person [] pool = new Person[POOL_SIZE]; 
   static 
   { 
      for (int i=0; i<POOL_SIZE; i++) 
      { 
         pool[i] = new Person(); 
      } 
   } 

   public static Person getUnusedInstance() 
   { 
      for (int i=0; i<POOL_SIZE; i++) 
      { 
         if ( pool[i].getReferenceCount == 0 )  
         { 
            return pool[i]; 
         } 
      } 
      return new Person(); 
   } 
} 

public class SomeClass  
{         
   public void doSomething() 
   { 
      ... 
      Person person = PersonPool.getUnusedInstance(); 
      person.increaseReferenceCount(); 
      person.doInit("Jan Kowalski", new Date()); 
      ... 
      writePerson(person); 
      ... 
      person.decreaseReferenceCount(); 
      ... 
   }
     
   public void writePerson(Person person) 
   { 
      person.increaseReferenceCount(); 
      .... 
      person.decreaseReferenceCount(); 
   } 
} 
