Code example for ReentrantLock

Methods: isHeldByCurrentThreadlockunlock

0
 
    void sync() { 
        assert SwingUtilities.isEventDispatchThread(); 
        assert !isLockedByCurrentThread(); 
 
        lock.lock();
        try { 
            rootNode.sync(true);
 
            visibleResultCount += addResultCount;
 
            addResultCount = 0;
 
            nodeChanged(rootNode);
        } finally { 
            lock.unlock();
        } 
    } 
 
    void setSearchState(LDAPSearchState newSearchState) {
        if (this.searchState != newSearchState) {
            this.searchState = newSearchState;
 
            if ((newSearchState != null)
                    && (newSearchState != LDAPSearchState.IN_PROGRESS))
            { 
                searchTask = null;
            } 
 
            nodeChanged(rootNode);
        } 
    } 
 
    boolean isLockedByCurrentThread() { 
        return lock.isHeldByCurrentThread();
    } 
}