Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

Latch Class

A latch is a boolean condition that is set at most once, ever. Once a single release is issued, all acquires will pass.

Sample usage. Here are a set of classes that use a latch as a start signal for a group of worker threads that are created and started beforehand, and then later enabled.

class Worker implements IRunnable { private readonly Latch startSignal; Worker(Latch l) { startSignal = l; } public void Run() { startSignal.acquire(); DoWork(); } void DoWork() { ... } } class Driver { // ... void Main() { Latch go = new Latch(); for (int i = 0; i < N; ++i) // make threads new Thread(new ThreadStart(new Worker(go)).Start(); DoSomethingElse(); // don't let run yet go.Release(); // let all threads proceed } }

For a list of all members of this type, see Latch Members .


[Visual Basic]
Public Class Latch
    Implements ISync
public class Latch : ISync

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


Namespace: Spring.Threading

Assembly: Spring.Core (in Spring.Core.dll)

See Also

Latch Members | Spring.Threading Namespace