@@ -0,0 +1,1523 @@
+package net.sf.kerner.utils.concurrent;%0A%0Apublic class BlockingElement%3CT%3E %7B%0A%0A    private final Object lock;%0A%0A    private T t = null;%0A%0A    private boolean released = false;%0A%0A    public BlockingElement() %7B%0A        this(new Object());%0A    %7D%0A%0A    public BlockingElement(final Object lock) %7B%0A        this.lock = lock;%0A    %7D%0A%0A    /**%0A     * Blocks until %7B@code t%7D becomes available.%0A     *%0A     * @return %7B@code t%7D or %7B@code null%7D if lock was released%0A     * @see #releaseLock()%0A     * @throws InterruptedException%0A     */%0A    public T get() throws InterruptedException %7B%0A        synchronized (lock) %7B%0A            while (t == null && !released) %7B%0A                lock.wait();%0A            %7D%0A            return t;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Does not block.%0A     * %0A     * @return %7B@code true%7D if %7B@code t%7D is not %7B@code null%7D or if block was%0A     *         released; %7B@code false%7D otherwise%0A     * @see #releaseLock()%0A     */%0A    public boolean isAvailable() %7B%0A        // Must not block%0A        synchronized (lock) %7B%0A            return t != null %7C%7C released;%0A        %7D%0A    %7D%0A%0A    public void releaseLock() %7B%0A        synchronized (lock) %7B%0A            this.released = true;%0A            lock.notifyAll();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Does not block.%0A     */%0A    public void set(final T t) %7B%0A        if (t == null)%0A            throw new IllegalArgumentException();%0A        // Must not block%0A        synchronized (lock) %7B%0A            this.released = false;%0A            this.t = t;%0A            lock.notifyAll();%0A        %7D%0A    %7D%0A%7D%0A

Introduce BlockingElement.