Class ConcurrentValue<T>

java.lang.Object
org.eclipse.net4j.util.concurrent.ConcurrentValue<T>

public final class ConcurrentValue<T> extends Object
Allow synchronization between many threads for a specific value.
 MainThread cv.set(1);
 Thread1 cv.acquire(3);
 Thread2 cv.acquire(4);
 Thread3 cv.acquire(100);
 Thread4 cv.acquire(new Object()
   {
     public boolean equals(Object other)
     {
       return other.equals(2) || other.equals(3);
     }
   });
 Thread5 cv.acquire(1);
 ...
 // Thread 1,2,3 and 4 are blocked
 // Thread 5 isn't blocked.

 MainThread cv.set(3);

 // Thread 1 and 4 are unblocked.
 // Thread 2 and 3 are still blocked.
 
Since:
2.0
Author:
Simon McDuff
  • Constructor Details

    • ConcurrentValue

      public ConcurrentValue(T value)
  • Method Details

    • get

      public T get()
    • set

      public void set(T newValue)
      Specify the new value.
    • reevaluate

      public void reevaluate()
      Reevaluate the condition. It is only useful if a thread is blocked at acquire(Object) and the parameter passed changed. acquire(Object) generates a reevaluation automatically.
    • acquire

      public void acquire(Object accept) throws InterruptedException
      Blocking call.

      Return when value accept is equal to get().

      Throws:
      InterruptedException