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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:06:44+00:00 2026-06-07T22:06:44+00:00

I want to know the basic difference between shutdown() and shutdownNow() for shutting down

  • 0

I want to know the basic difference between shutdown() and shutdownNow() for shutting down the Executor Service?

As far as I understood:

shutdown() should be used for graceful shutdown which means all tasks that were running and queued for processing but not started should be allowed to complete

shutdownNow() does an abrupt shut down meaning that some unfinished tasks are cancelled and unstarted tasks are also cancelled. Is there anything else which is implicit/explicit that I am missing?

P.S: I found another question on How to shutdown an executor service related to this but not exactly what I want to know.

  • 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-07T22:06:46+00:00Added an answer on June 7, 2026 at 10:06 pm

    In summary, you can think of it that way:

    • shutdown() will just tell the executor service that it can’t accept new tasks, but the already submitted tasks continue to run
    • shutdownNow() will do the same AND will try to cancel the already submitted tasks by interrupting the relevant threads. Note that if your tasks ignore the interruption, shutdownNow will behave exactly the same way as shutdown.

    You can try the example below and replace shutdown by shutdownNow to better understand the different paths of execution:

    • with shutdown, the output is Still waiting after 100ms: calling System.exit(1)... because the running task is not interrupted and continues to run.
    • with shutdownNow, the output is interrupted and Exiting normally... because the running task is interrupted, catches the interruption and then stops what it is doing (breaks the while loop).
    • with shutdownNow, if you comment out the lines within the while loop, you will get Still waiting after 100ms: calling System.exit(1)... because the interruption is not handled by the running task any longer.
    public static void main(String[] args) throws InterruptedException {
        ExecutorService executor = Executors.newFixedThreadPool(1);
        executor.submit(new Runnable() {
    
            @Override
            public void run() {
                while (true) {
                    if (Thread.currentThread().isInterrupted()) {
                        System.out.println("interrupted");
                        break;
                    }
                }
            }
        });
    
        executor.shutdown();
        if (!executor.awaitTermination(100, TimeUnit.MICROSECONDS)) {
            System.out.println("Still waiting after 100ms: calling System.exit(1)...");
            System.exit(1);
        }
        System.out.println("Exiting normally...");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know what is the basic difference between these to files -
I want to simply know the basic difference between failed test and broken test
The thing I want to know here should be really 'basic', but it is
Language Visual Basic 6. I want to know if there is an open source
I'm playing with TI-83+ BASIC development. But I want to know if I can
Pretty basic question, I know... I just don't know how it's done. I want
Basic question: what design principles should one follow when choosing between using a class
I want to know about Virtualization in detail. But start from basics, like what
i want know how i can manage multiple twitter account on iOS in my
i want know if is possible, to get a specific element value of a

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.