stanfordnlp/CoreNLP · warning
-threads [number]: was not given a valid number:
Error message
-threads [number]: was not given a valid number:
What it means
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.
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
Example fix
// before java StanfordCoreNLP -threads auto -filelist f.txt // after java StanfordCoreNLP -threads 8 -filelist f.txt
Defensive patterns
Strategy: validation
Validate before calling
int threads = 1;
if (argsThreads != null && argsThreads.matches("\\d+")) {
threads = Integer.parseInt(argsThreads);
} Prevention
- 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
When it happens
Trigger: Running java StanfordCoreNLP -threads "four" or -threads 4x or any non-numeric string; parseThreads-like helper in StanfordCoreNLP main catches NumberFormatException.
Common situations: 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.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- TaggedFileRecord argument
- Unknown argument:
- Unknown argument " + args[argIndex]
- Unknown argument " + args[argIndex]
- Unknown argument " + args[argIndex]
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a6d824e7d4a656e7.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java:1437
}
public void run() throws IOException {
run(false);
}
public void run(boolean clearPool) throws IOException {
Timing tim = new Timing();
StanfordRedwoodConfiguration.minimalSetup();
// multithreading thread count
String numThreadsString = this.properties.getProperty("threads");
int numThreads = 1;
try {
if (numThreadsString != null) {
numThreads = Integer.parseInt(numThreadsString);
}
} catch (NumberFormatException e) {
logger.err("-threads [number]: was not given a valid number: " + numThreadsString);
}
// blank line after all the loading statements to make output more readable
logger.info("");
//
// Process one file or a directory of files
//
if (properties.containsKey("file") || properties.containsKey("textFile")) {
String fileName = properties.getProperty("file");
if (fileName == null) {
fileName = properties.getProperty("textFile");
}
Collection<File> files = new FileSequentialCollection(new File(fileName), properties.getProperty("extension"), true);
this.processFiles(null, files, numThreads, clearPool, Optional.of(tim));
}
//View on GitHub (pinned to 1b7edd19c4)