@@ -0,0 +1,759 @@
+/**%0A * %0A */%0Apackage com.trendrr.oss.concurrent;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0A%0A%0A/**%0A * Simple threadsafe lazy init object.%0A * %0A * usage:%0A * %0A * LazyInit%3CMyObject%3E obj = new LazyInit%3CMyObject%3E() %7B%0A * %09@Override%0A * %09public MyObject init() %7B%0A * %09%09return new MyObject();%0A * %09%7D%0A * %7D%0A * %0A * %0A * MyObject my = obj.get();%0A * %0A * @author Dustin Norlander%0A * @created Aug 31, 2011%0A * %0A */%0Apublic abstract class LazyInitObject%3CT%3E %7B%0A%0A%09protected Log log = LogFactory.getLog(LazyInitObject.class);%0A%09%0A%09T object;%0A%09LazyInit lock = new LazyInit();%0A%09%0A%09public abstract T init();%0A%09%0A%09public T get() %7B%0A%09%09if (lock.start()) %7B%0A%09%09%09try %7B%0A%09%09%09%09this.object = this.init();%0A%09%09%09%7D finally %7B%0A%09%09%09%09lock.end();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return object;%0A%09%7D%0A%7D%0A

Add lazy init object