• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could newCachedThreadPool create indefinite number of threads and eventually crash JVM?

 
yuling chen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Just wondering if newCachedThreadPool could create indefinite number of threads and eventually crash JVM?

Thanks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By itself? Probably not, but if your threads consume memory, live a long time, and never release that thread - then yeah probably. If that is the case, you shouldn't be using a pool created by newCachedThreadPool (The API says they should be used for short lived threads), you should be using one with an upper bound of concurrent threads so you can control the number of tasks being used. You should also figure out why your threads are lasting so long and understand if that is what is intended...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!