You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2009/09/26 17:07:07 UTC
svn commit: r819148 -
/commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java
Author: oheger
Date: Sat Sep 26 15:07:07 2009
New Revision: 819148
URL: http://svn.apache.org/viewvc?rev=819148&view=rev
Log:
Accidently changed formatting in the previous commit.
Modified:
commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java
Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java?rev=819148&r1=819147&r2=819148&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/concurrent/LazyInitializer.java Sat Sep 26 15:07:07 2009
@@ -42,11 +42,9 @@
* to this class, a subclass of {@code LazyInitializer} has to be created:
*
* <pre>
- * public class ComplexObjectInitializer extends LazyInitializer<ComplexObject>
- * {
+ * public class ComplexObjectInitializer extends LazyInitializer<ComplexObject> {
* @Override
- * protected ComplexObject initialize()
- * {
+ * protected ComplexObject initialize() {
* return new ComplexObject();
* }
* }
@@ -77,8 +75,7 @@
* @version $Id$
* @param <T> the type of the object managed by this initializer class
*/
-public abstract class LazyInitializer<T>
-{
+public abstract class LazyInitializer<T> {
/** Stores the managed object. */
private volatile T object;
@@ -88,19 +85,15 @@
*
* @return the object initialized by this {@code LazyInitializer}
*/
- public T get()
- {
+ public T get() {
// use a temporary variable to reduce the number of reads of the
// volatile field
T result = object;
- if (result == null)
- {
- synchronized (this)
- {
+ if (result == null) {
+ synchronized (this) {
result = object;
- if (result == null)
- {
+ if (result == null) {
object = result = initialize();
}
}