@Deprecated public abstract class

ThreadsafeLazyLoadedReference

extends LazyReference<T>
java.lang.Object
   ↳ java.lang.ref.Reference<T>
     ↳ java.lang.ref.WeakReference<T>
       ↳ com.atlassian.util.concurrent.LazyReference<T>
         ↳ com.atlassian.jira.util.concurrent.ThreadsafeLazyLoadedReference<V>

This class is deprecated.
Switch to LazyReference instead.

Class Overview

Thread-safe lock-less (see note) reference that is not constructed until required. This class is used to maintain a reference to an object that is expensive to create and must be constructed once and once only. Therefore this reference behaves as though the final keyword has been used (you cannot reset it once it has been constructed).

When using this class you need to implement the create() method to return the object this reference will hold.

For instance:

 final ThreadsafeLazyLoadedReference ref = new ThreadsafeLazyLoadedReference()
 {
     protected Object create() throws Exception
     {
         // Do some useful object construction here
         return new MyObject();
     }
 };
 

Then call to get a reference to the object:

   MyObject myLazyLoadedObject = (MyObject) ref.get()
 

Interruption policy is that if you want to be cancellable while waiting for another thread to create the value, instead of calling get() call getInterruptibly(). If your create() method throws an InterruptedException however, it will be the causal exception inside the runtime exception that get() or getInterruptibly() throws and your create() will not be called again.

Summary

Public Constructors
ThreadsafeLazyLoadedReference()
[Expand]
Inherited Methods
From class com.atlassian.util.concurrent.LazyReference
From class java.lang.ref.Reference
From class java.lang.Object
From interface com.atlassian.util.concurrent.Supplier
From interface com.google.common.base.Supplier

Public Constructors

public ThreadsafeLazyLoadedReference ()