{"record":{"id":"a6d824e7d4a656e7","repo":"stanfordnlp/CoreNLP","slug":"threads-number-was-not-given-a-valid-number","errorCode":null,"errorMessage":"-threads [number]: was not given a valid number: ","messagePattern":"-threads \\[number\\]: was not given a valid number: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java","lineNumber":1437,"sourceCode":"  }\n\n  public void run() throws IOException {\n    run(false);\n  }\n\n  public void run(boolean clearPool) throws IOException {\n    Timing tim = new Timing();\n    StanfordRedwoodConfiguration.minimalSetup();\n\n    // multithreading thread count\n    String numThreadsString = this.properties.getProperty(\"threads\");\n    int numThreads = 1;\n    try {\n      if (numThreadsString != null) {\n        numThreads = Integer.parseInt(numThreadsString);\n      }\n    } catch (NumberFormatException e) {\n      logger.err(\"-threads [number]: was not given a valid number: \" + numThreadsString);\n    }\n\n    // blank line after all the loading statements to make output more readable\n    logger.info(\"\");\n\n    //\n    // Process one file or a directory of files\n    //\n    if (properties.containsKey(\"file\") || properties.containsKey(\"textFile\")) {\n      String fileName = properties.getProperty(\"file\");\n      if (fileName == null) {\n        fileName = properties.getProperty(\"textFile\");\n      }\n      Collection<File> files = new FileSequentialCollection(new File(fileName), properties.getProperty(\"extension\"), true);\n      this.processFiles(null, files, numThreads, clearPool, Optional.of(tim));\n    }\n\n    //","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java#L1419-L1455","documentation":"StanfordCoreNLP's -threads command-line option must parse as an integer. When Integer.parseInt fails on the provided value, this error message is logged and the thread count silently falls back to the default of 1.","triggerScenarios":"Running java StanfordCoreNLP -threads \"four\" or -threads 4x or any non-numeric string; parseThreads-like helper in StanfordCoreNLP main catches NumberFormatException.","commonSituations":"Shell quoting issues or typos; passing a comma list like -threads 2,4; copy-pasting options from another tool; expecting the flag name to be --threads instead of -threads so the value string is odd.","solutions":["Pass a plain integer, e.g. -threads 4","Quote the value in the shell if needed: -threads \"4\"","Verify no stray characters (units, commas) after the number","Remember the fallback is 1 thread; check output timing if performance matters"],"exampleFix":"// before\njava StanfordCoreNLP -threads auto -filelist f.txt\n// after\njava StanfordCoreNLP -threads 8 -filelist f.txt","handlingStrategy":"validation","validationCode":"int threads = 1;\nif (argsThreads != null && argsThreads.matches(\"\\\\d+\")) {\n    threads = Integer.parseInt(argsThreads);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass -threads as a bare positive integer","Quote arguments in shell scripts to avoid stray characters","Check logs after startup to confirm the intended thread count took effect"],"tags":["cli","argument-parsing","threads"],"backgroundTag":"invalid-cli-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}