#vulnerable code 
                                public VanillaFile dataForLast(int cycle, int threadId) throws IOException {
        String cycleStr = dateCache.formatFor(cycle);
        String dataPrefix = basePath + "/" + cycleStr + "/data-" + threadId + "-";
        if (lastCycle != cycle) {
            int maxCount = 0;
            File[] files = new File(dataPrefix).listFiles();
            if (files != null)
                for (File file : files) {
                    if (file.getName().startsWith(dataPrefix)) {
                        int count = Integer.parseInt(file.getName().substring(dataPrefix.length()));
                        if (maxCount < count)
                            maxCount = count;
                    }
                }
            lastCycle = cycle;
            lastCount = maxCount;
        }

        return dataFor(cycle, threadId, lastCount, true);
    } 
                            #location 2 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public VanillaFile dataForLast(int cycle, int threadId) throws IOException {
        String cycleStr = dateCache.formatFor(cycle);
        String cyclePath = basePath + "/" + cycleStr;
        String dataPrefix = "data-" + threadId + "-";
        if (lastCycle != cycle) {
            int maxCount = 0;
            File[] files = new File(cyclePath).listFiles();
            if (files != null)
                for (File file : files) {
                    if (file.getName().startsWith(dataPrefix)) {
                        int count = Integer.parseInt(file.getName().substring(dataPrefix.length()));
                        if (maxCount < count)
                            maxCount = count;
                    }
                }
            lastCycle = cycle;
            lastCount = maxCount;
        }

        return dataFor(cycle, threadId, lastCount, true);
    }