org.jlab.coda.afecs.system.util
Class GuardedBlock
java.lang.Object
org.jlab.coda.afecs.system.util.GuardedBlock
public class GuardedBlock
- extends java.lang.Object
JSA: Thomas Jefferson National Accelerator Facility
This software was developed under a United States Government license,
described in the NOTICE file included as part of this distribution.
Copyright (c), Feb 5, 2010
This class is used sender-receiver applications. This kind of application
shares data between two threads: the sender, that creates the data, and the
receiver, that does something with it. The two threads communicate using a
shared object. Coordination is essential: the receiver thread must not attempt
to retrieve the data before the sender thread has delivered it, and the sender
thread must not attempt to send new data if the receiver hasn't retrieved the old data.
- Version:
- 1.4
- Author:
- Vardan Gyurjyan
Method Summary |
void |
put(java.lang.Object o)
Waits until object is retrived and puts the new object into the local repository. |
java.lang.Object |
take()
Waits until object is available and returns it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GuardedBlock
public GuardedBlock()
put
public void put(java.lang.Object o)
- Waits until object is retrived and puts the new object into the local repository.
- Parameters:
o
- Object to store locally
take
public java.lang.Object take()
- Waits until object is available and returns it.
- Returns:
- object