#vulnerable code 
                              public static int checkArgs(String[] args, Type typ) {
    int debugLevel = -99;
    List<String> options = new ArrayList<String>();
    options.addAll(Arrays.asList(args));
    for (int n = 0; n < options.size(); n++) {
      String opt = options.get(n);
      if (!opt.startsWith("-")) {
        continue;
      }
      if (opt.startsWith("-d")) {
        debugLevel = -1;
        try {
          debugLevel = n + 1 == options.size() ? -1 : Integer.decode(options.get(n + 1));
        } catch (Exception ex) {
          debugLevel = -1;
        }
        if (debugLevel > -1) {
          Debug.on(debugLevel);
        }
      }
      if (Type.IDE.equals(typ) && debugLevel == -1) {
        Debug.on(3);
        Debug.log(3, "RunTime: option -d detected --- log goes to SikulixLog.txt");
        Debug.setLogFile("");
        Settings.LogTime = true;
        System.setProperty("sikuli.console", "false");
      }
    }
    return debugLevel;
  } 
                            #location 24 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                              public static int checkArgs(String[] args, Type typ) {
    int debugLevel = -99;
    boolean runningScriptsWithIDE = false;
    List<String> options = new ArrayList<String>();
    options.addAll(Arrays.asList(args));
    for (int n = 0; n < options.size(); n++) {
      String opt = options.get(n);
      if (!opt.startsWith("-")) {
        continue;
      }
      if (opt.startsWith("-d")) {
        debugLevel = -1;
        try {
          debugLevel = n + 1 == options.size() ? -1 : Integer.decode(options.get(n + 1));
        } catch (Exception ex) {
          debugLevel = -1;
        }
        if (debugLevel > -1) {
          Debug.on(debugLevel);
        }
      } else if (opt.startsWith("-r") || opt.startsWith("-t")) {
        runningScriptsWithIDE = true;
      }
    }
    if (Type.IDE.equals(typ) && runningScriptsWithIDE) {
      return 999;
    }
    return debugLevel;
  }