public Runnable take() throws InterruptedException
    {
        lock.lockInterruptibly();
        try {
            try {
                ChannelsRunnable r = null;
                while(r == null) {
                    r = getAvailableRunnable();
                    if(r != null)
                        break;
                    hasAvailableRunnable.await();
                }
                return r;
            } catch (InterruptedException ie) {
                hasAvailableRunnable.signal(); // propagate to non-interrupted thread
                throw ie;
            }
        } finally {
            lock.unlock();
        }
    }