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

  • SEARCH
  • Home
  • 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 3786830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:44:40+00:00 2026-05-19T11:44:40+00:00

Using Java and App Server I deploy application that has a thread executer. During

  • 0

Using Java and App Server I deploy application that has a thread executer.

During un-deploy I request the executer to shutdown. This successfully cancels all the tasks. However via VisualVM I can still see a thread that represents the executer itself and it is in the wait sate. I don’t keep any references to the executer as the whole application get undeployed. So if i repeat the deployment-undeployment cycle multiple times I can see how the threads number grows.

How do I get rid of them?

UPDATE:

code example

here is the code:

public void startScheduler()
{
    if (scheduledExecutor == null)
    {
        scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("My ScheduledExecutor"));
        processFuture = scheduledExecutor.scheduleAtFixedRate(new Runnable()
            {
                @Override
                public void run()
                {
                    startProcessor();
                }
            }, 0, 84600, TimeUnit.SECONDS);
    }
}


public void stopScheduler()
{

    if (processFuture != null)
    {
        processFuture.cancel(true);
        processFuture = null;
    }

    if (scheduledExecutor != null)
    {
        try
        {
            scheduledExecutor.shutdownNow();
            scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS);
        }
        catch (InterruptedException ignored)
        {}
        finally
        {
            scheduledExecutor = null;
        }
    }

}
  • 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-05-19T11:44:41+00:00Added an answer on May 19, 2026 at 11:44 am

    Could you please elaborate what you mean with “a thread that represents the executer itself”. What is it’s name/id/threadgroup? I don’t think executor service creates such a thread.

    Executors create new threads (using the configurable ThreadFactory). A Thread automatically inherits some properties of its parent, that is the Thread.currentThread(). The most problematic part of this behavior in a web application scenario with deploy/undeploy cycles however is the Thread’s ContextClassLoader, which is inherited from the parent’s thread. If your ContextClassLoader holds on to classes from within your web application archive, then the spawned Executors Thread will also have a reference to this ClassLoader. If the code which is executed by the Executor has e.g. ThreadLocals with classes from the WebappClassLoader, you may experience a ClassLoader leak problem.

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

Sidebar

Related Questions

I am using Apache Axis to connect my Java app to a web server.
I've created an app that interacts with a SOAP service using java WS. I
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
have a weird situation. I'm using Glassfish server for my Enterprise application. In that
I have this java swing application that I intend to sell over the internet.
I'm writing a java app using eclipse which references a few external jars and
I'm building a little app using Java and Swing in NetBeans. Using NetBeans design
Possible Duplicate: How do you send email from a Java app using Gmail? How
I'm using Hibernate for ORM of my Java app to an Oracle database (not

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.