• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Constantly increasing number of JVM threads ?ScheduledExecutorService responsible

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a spring-boot microservice (using mongodb, camel and kafka), whose jvm threads keep rising (and never falling)

As part of processing a large number of messages, I am using a ScheduledExecutorService to schedule tasks to run at variable periods (15 or 30 minutes) in the future to check state at the future time and compare it to the time when the message was first processed (and the ScheduledFuture was created)

I am injecting the ActionExecutor below into another class, which calls its the ActionExecutor's methods by reflection (in case this makes any difference)



My assumption was that after the scheduled run of alerter happened, the thread provided by the ScheduledThreadPool to run the alerter runnable would be disposed of automatically, but is this wrong?

Should I be doing something at the end of the alerter run method to dispose of the ScheduledFuture (alertHandle) and/or stop the thread somehow?

Could this be responsible for the constantly increasing count of threads being generated?

If this does not look like a likely candidate for where the problem may lie, has anyone any ideas on how to track down what might be creating all these threads?

Thanks very much for any help you can give me,

Regards,

Tim

 
Timothy Jones
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS the process which uses the ActionExecutor is a continuously-running process , so there is no opportunity to  shutdown the scheduler as it should be constantly busy scheduling new tasks
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The stuff in runnable, is it having some kind of while(true) loop with sleep?
That is the only case I see which can increase the number of threads...

Another question is why not make use of Spring provided @Async?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic