• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • 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?
 
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic