Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:21:10+00:00 2026-06-15T22:21:10+00:00

I have an tomcat webapp where I use a java executor to execute some

  • 0

I have an tomcat webapp where I use a java executor to execute some runnables.

First I allocate the executor service from my executor instance like this:

executorService = Executors.newFixedThreadPool(nThreads, new MyThreadFactory(threadFactoryName))

Then, I launch task using the executor service:

executorService.execute(new MyRunnable);

Then, it seems to work. But my problem is, I am chasing some sort of leak where I get this error after a while of running the server:

Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:640)
at java.util.concurrent.ThreadPoolExecutor.addIfUnderCorePoolSize(ThreadPoolExecutor.java:703)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:652)
at something.server.ThreadExecutor.execute(MyRunnable.java:91)

I used the java VisualVM on tomcat instance to trace the thread allocation. I see that when I call ‘newFixedThreadPool’ I see ‘nThreads’ new threads. But after their job is done, I see the state of the threads to be on ‘wait’.

Is that normal? I don’t believe it is, I know the runnables finish their job but the executor service never frees the threads. What can I do to free them, or am I completely out of scope?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:21:11+00:00Added an answer on June 15, 2026 at 10:21 pm

    I think you are instantiating a new ExecutorService for every request, or something like that.

    You should either instantiate only one ExecutorService, and reuse it, or call shutdown() on the service after you have finished submitting tasks. The shutdown function will wait for the tasks to finish, and then free the threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java webapp, running in Tomcat 6, that loads RSS feeds from
I have a Tomcat Java webapp which is thrashing the Java GC when under
I have a Tomcat 5.5 running which includes a Webapp with the Java Reporting
i'm attempting to use apache tomcat 7.0 tomcat7 to access java servlets. I have
I have a problem with Tomcat 5.5 and Java EE webapp libraries. I'm using
I'm using VisualVM from JDK 1.6.0_26 to profile a Java webapp running under Tomcat,
We have a Tapestry-Spring-Hibernate webapp running on Tomcat 6, handing about a few 1000
I have a crazy request about restarting tomcat server through my webapp. I was
I have a Struts2 webapp, in which I compiled using the Tomcat 5.5 libraries.
multiple webapp running on same tomcat using same jvm. sometime, one webapp that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.