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 7701901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:06:17+00:00 2026-05-31T23:06:17+00:00

I have a ScheduledExecutorService and I do a task every 15 mins (in a

  • 0

I have a ScheduledExecutorService and I do a task every 15 mins (in a web application in Tomcat).
In a ServletContextListener in contextDestroyed I have done:

Runtime.getRuntime().addShutdownHook(new Thread(){  
            @Override  
            public void run(){  
                scheduler.shutdown();   
            }   
        });    

The scheduler is started like:

final Runnable r = new Runnable(){

            @Override
            public void run() {
                System.out.println("My task");
                //Do some task
            }

        };
updater.scheduleWithFixedDelay(r, 30, 15, TimeUnit.MINUTES);

Question:On shutdown any remaining task isn’t executed.
There is a task running but I don’t see any logs so it seems it is not executed. Why?

UPDATE:
If I start tomcat and then after 2 mins I shutdown then isn’t the task considered as scheduled and must run? I mean if a task is submitted isn’t it considered as pending? Or it must be actually running?

  • 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-31T23:06:18+00:00Added an answer on May 31, 2026 at 11:06 pm

    I can’t quite parse your question but maybe your application is not exiting like you’d expect?

    Shutting down an Executor will stop any tasks for being submitted but any running tasks will continue to run until they exit. From the shutdown() javadocs:

    Initiates an orderly shutdown in which previously submitted
    tasks are executed, but no new tasks will be accepted.
    Invocation has no additional effect if already shut down.

    If you edit your question to be more clear we can answer more appropriately.

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

Sidebar

Related Questions

Have a n-tire web application and search often times out after 30 secs. How
I have following code which call a task after every 20 min and its
I am having this problem, I have private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); and task
I am using ScheduledExecutorService to run scheduled threads. I implemented ServletContextListener.contextDestroyed and invoked ScheduledExecutorService.shutdownNow
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have a question regarding the scheduleAtFixedRate() method on ScheduledExecutorService in Java 6. [
I have a poller implemented from Runnable. The poller passes itself into a ScheduledExecutorService.
i currently have a list of classes every class starts a scheduler like this:
I have a long-lived server application that is designed to run with minimal downtime
Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing

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.