#vulnerable code 
                                public boolean processing(long height) {
        if (chainList.isEmpty()) {
            return false;
        }
        lock.lock();
        try {
            List<String> hashList = this.getHashList(height);
            if (hashList.size() == 1) {
                return true;
            }
            if (hashList.isEmpty()) {
                Log.warn("lost a block:" + height);
                return false;
            }
            List<BlockHeaderChain> longestChainList = new ArrayList<>();
            int size = 0;
            for (BlockHeaderChain chain : chainList) {
                if (chain.size() == size) {
                    longestChainList.add(chain);
                } else if (chain.size() > size && size == 0) {
                    longestChainList.add(chain);
                } else if (chain.size() > size && size != 0) {
                    longestChainList.clear();
                    longestChainList.add(chain);
                }
            }
            if (longestChainList.size() != 1) {
                return false;
            }
            chainList = longestChainList;
            return true;
        } finally {
            lock.unlock();
        }
    } 
                            #location 2 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public boolean processing(long height) {
        if (chainList.isEmpty()) {
            return false;
        }
        List<String> hashList = this.getHashList(height);
        if (hashList.size() == 1) {
            return true;
        }
        if (hashList.isEmpty()) {
            Log.warn("lost a block:" + height);
            return false;
        }
        int maxSize = 0;
        int secondMaxSize = 0;
        for (BlockHeaderChain chain : chainList) {
            int size = chain.size();
            if (size > maxSize) {
                secondMaxSize = maxSize;
                maxSize = size;
            } else if (size > secondMaxSize) {
                secondMaxSize = size;
            } else if (size == maxSize) {
                secondMaxSize = size;
            }
        }
        if (maxSize <= (secondMaxSize + 6)) {
            return false;
        }
        for (int i = chainList.size() - 1; i >= 0; i--) {
            if (chainList.size() < maxSize) {
                chainList.remove(i);
            }
        }
        return true;
    }