Search in sources :

Example 16 with WriteLock

use of java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock in project jgnash by ccavanaugh.

the class AbstractExpandingTableModel method restoreExpansionState.

private void restoreExpansionState(final String state) {
    WriteLock writeLock = rwl.writeLock();
    writeLock.lock();
    try {
        if (state != null && state.length() == objects.size()) {
            ArrayList<ExpandingTableNode<E>> values = new ArrayList<>(objects.values());
            Collections.sort(values);
            for (int i = 0; i < state.length(); i++) {
                values.get(i).setExpanded(state.charAt(i) == '1');
            }
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : WriteLock(java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ArrayList(java.util.ArrayList)

Aggregations

WriteLock (java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock)16 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)15 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 BinaryOutputArchive (org.apache.jute.BinaryOutputArchive)1 Proposal (org.apache.zookeeper.server.quorum.Leader.Proposal)1 QuorumPacket (org.apache.zookeeper.server.quorum.QuorumPacket)1