Oracle® Fusion Middleware .NET API Reference for Oracle Coherence
12c (12.2.1.4.0)
E90869-02
Use this class in cases that large numbers of threads can operate concurrently with an additional requirement that all threads be blocked for certain operations.

Namespace: Tangosol.Util
Assembly: Coherence (in Coherence.dll) Version: 12.2.1.4014 (12.2.1.4014)

Syntax

C#
[ObsoleteAttribute("Use GateFactory.NewGate to obtain a Gate.")]
public class ThreadGate : Gate

Remarks

The algorithm is based on a gate concept, allowing threads in Enter(Int64) and out Exit()()()(), but occasionally shutting the gate Close(Int64) such that other threads cannot enter and exit. However, since threads may "be inside", the gate cannot fully close until they leave Exit()()()(). Once all threads are out, the gate is closed, and can be re-opened Open()()()() or permanently closed Destroy()()()().

Each call to Enter requires a corresponding call to Exit. For example, the following would ensure proper clean-up using a ThreadGate:

            gate.Enter();
            try
            {
                ...
            }
            finally
            {
                gate.Exit();
            }
            

Similarly, each call to Close should be matched with a call to Open, unless the gate is being destroyed:

            gate.Close();
            try
            {
                ...
            }
            finally
            {
                gate.Open();
            }
            

or:

            gate.Close();
            gate.Destroy();
            

The Enter/Exit calls can be nested; the same thread can invoke Enter multiple times as long as Exit is invoked a corresponding number of times. The Close/Open calls work in the same manner. Lastly, the thread that closes the gate may continue to Enter/Exit the gate even when it is closed since that thread has exclusive control of the gate.

Inheritance Hierarchy

System..::..Object
  Tangosol.Util..::..ThreadGate

See Also