// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.*;

// singleton klasse
public class S4 {
   // normale attributter eksemplificeret ved en List
   private List list;
   // den eneste instans der eksisterer
   private static S4 instance = null;
   // private constructor
   private S4() {
      list = new ArrayList();
   }
   // public static metode til at hente instance
   public static S4 getInstance() {
      if(instance == null) {
         synchronized(S4.class) {
            if(instance == null) {
               instance = new S4();
            }
         }
      }
      return instance;
   }
   // normale metoder
   public synchronized void add(Object o) {
      list.add(o);
   }
   public List getList() {
      return list;
   }
}
