The class below seems to consistently report 2542 threads being the maximum possible, irrespective of memory allocated to the app. What is limiting the number of threads here? Memory, CPU, internal JVM setting?
Thanks
public static void main(String... args) {
int taskNumber = 0;
while (true) {
try {
new MyThread().start();
} catch (OutOfMemoryError e) {
System.out.println("Thread " + taskNumber+" could not be created.");
System.exit(0);
}
taskNumber++;
}
}