#vulnerable code 
                                public void bind(boolean wholeCore) {
        if (bound && assignedThread != null && assignedThread.isAlive())
            throw new IllegalStateException("cpu " + id + " already bound to " + assignedThread);

        if (wholeCore) {
            int core = coreForId(id);
            for (AffinityLock al : CORES[core]) {
                if (bound && al.assignedThread != null && al.assignedThread.isAlive()) {
                    LOGGER.severe("cpu " + al.id + " already bound to " + al.assignedThread);
                } else {
                    al.bound = true;
                    al.assignedThread = Thread.currentThread();
                }
            }
            if (LOGGER.isLoggable(Level.INFO)) {
                StringBuilder sb = new StringBuilder().append("Assigning core ").append(core);
                String sep = ": cpus ";
                for (AffinityLock al : CORES[core]) {
                    sb.append(sep).append(al.id);
                    sep = ", ";
                }
                sb.append(" to ").append(assignedThread);
                LOGGER.info(sb.toString());
            }
        } else {
            bound = true;
            assignedThread = Thread.currentThread();
            if (LOGGER.isLoggable(Level.INFO))
                LOGGER.info("Assigning cpu " + id + " to " + assignedThread);
        }
        AffinitySupport.setAffinity(1L << id);
    } 
                            #location 7 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public void bind(boolean wholeCore) {
        if (bound && assignedThread != null && assignedThread.isAlive())
            throw new IllegalStateException("cpu " + id + " already bound to " + assignedThread);

        if (wholeCore) {
            int core = coreForId(id);
            for (AffinityLock al : CORES.get(core)) {
                if (bound && al.assignedThread != null && al.assignedThread.isAlive()) {
                    LOGGER.severe("cpu " + al.id + " already bound to " + al.assignedThread);
                } else {
                    al.bound = true;
                    al.assignedThread = Thread.currentThread();
                }
            }
            if (LOGGER.isLoggable(Level.INFO)) {
                StringBuilder sb = new StringBuilder().append("Assigning core ").append(core);
                String sep = ": cpus ";
                for (AffinityLock al : CORES.get(core)) {
                    sb.append(sep).append(al.id);
                    sep = ", ";
                }
                sb.append(" to ").append(assignedThread);
                LOGGER.info(sb.toString());
            }
        } else {
            bound = true;
            assignedThread = Thread.currentThread();
            if (LOGGER.isLoggable(Level.INFO))
                LOGGER.info("Assigning cpu " + id + " to " + assignedThread);
        }
        AffinitySupport.setAffinity(1L << id);
    }