0

I have a java application deployed in Websphere server. I am using the thread pool in my application with size 150. apart from these, application server threads will be running. So is there a way to determine the maximum number of threads that can run in the application at any time?

EDIT: I mean is there a way I say that the thread count at any time will not exceed some fixed number?

I am not creating any other thread in the application.
Using the threadpoolexecutor with size 150 to create any threads.
+application server threads.

So like, I can say my application can create maximum of 150 threads can I say how much an application server create at the maximum?

Thanks

GuruKulki
  • 25,776
  • 50
  • 140
  • 201
  • There isn't a maximum, e.g. there is a GC thread per CPU by default, and threads can be started in code. Are you asking what is the largest number you should expect? – Peter Lawrey Mar 22 '16 at 14:56
  • 3
    Please use google before asking. This is my first google result: http://stackoverflow.com/a/763592/6077352 – PendingValue Mar 22 '16 at 14:56
  • 1
    Possible duplicate of [How many threads can a Java VM support?](http://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-support) – 3kings Mar 22 '16 at 14:57
  • http://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-support –  Mar 22 '16 at 15:12
  • All, I am not asking the maximum limit of threads a JVM can have. instead I am asking, can you say at any moment how many threads can run at the maximum? can I determine the number counting on all my configurations? – GuruKulki Mar 22 '16 at 15:16

2 Answers2

0

You don't have a specific number, the number of threads is limited by the JVM heap size. A pool of threads has a recommended number of threads equal to twice the number of cores that your computer has.

André Alves
  • 245
  • 1
  • 2
  • 12
0

No specific pre-defined number i guess, but in case of thread pool it's max integer value. Tried this code works on my local machine, so incase of threadpool max value will always be Integer.MAX_VALUE (per thread pool ofcourse).

 int threadCount=Integer.MAX_VALUE;
 ExecutorService executor = Executors.newFixedThreadPool(threadCount);
Dark Knight
  • 8,218
  • 4
  • 39
  • 58