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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:27:51+00:00 2026-05-25T00:27:51+00:00

Some questions about Executors best usage for memory and time performance: Is there any

  • 0

Some questions about Executors best usage for memory and time performance:

  1. Is there any cost penalty incurred for the use of

    ExecutorService e = Executors.newSingleThreadExecutor();
    e.execute(callable)
    e.shutdown()
    

    compared to:

    new Thread(runnable).start()
    
  2. If a Callable is not a long one, and never won’t be more than one instance running of it it’s ok to use the code from (1)? Or is it best to have ExecutorService as a static instance and reuse between calls?

  3. If I have several tasks as described in (2) is there any problem with every task to having its own executor service or is better to have a centralized one? (I’m talking about a client application where normally there won’t be more than one of these tasks running)

  4. What resources does an Executor consume if it isn’t shutdown()?

  • 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-25T00:27:52+00:00Added an answer on May 25, 2026 at 12:27 am

    Is there any cost penalty from using

    ExecutorService e=Executors.newSingleThreadExecutor();
    e.execute(callable)
    e.shutdown()
    

    compared to:

    new Thread(runnable).start()
    

    Yes, there is a “penalty”: the ExecutorService will most likely be more expensive to create since it also creates a queue for the tasks you’re submitting and if a thread fails prior to shutdown, then the failed thread will be replaced with another one in order to run any subsequent tasks (so there is quite a bit of logic there). However, you probably don’t want to be creating an ExecutiveService each time you want to run a task… that’s probably not the best use of an ExecutorService (more on that in the next question).

    If a Callable is not a long one, and never won’t be more than one instance running of it it’s ok to use the code from -1-? Or it’s best to have ExecutorService as static one and reuse between calls?

    The suggested use of the ExecutorService is as a thread pool, where you keep the ExecutorService around and you keep submitting tasks to it as long as you have tasks to submit. It can be static or just a regular member, that is irrelevant and highly dependent on your requirements/design. Even if you’re only running one instance at a time (i.e. you only have a single-threaded executor), it’s still more efficient to use the ExecutorService because it reuses the thread, so in the long run it will be less expensive than creating a new thread for each task you submit.

    If I have several task… is there any problem for every task to have their executor service or is better to have a centralized one?

    There is no problem, but it’s inefficient, so just have a centralized executor service.

    What resources consumes an Executor if it isn’t shutdown()?

    I don’t think you should worry about that in particular, especially if you’re using the Executor in the correct context it will be minimal.

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

Sidebar

Related Questions

There have been some questions about whether or not JavaScript is an object-oriented language.
I have some questions about multi-threaded programming and multi-core usage. In particular I'm wondering
I have some questions about partitioning and strategy, how and when to use it.
i have some questions about constructors in ColdFusion : must i use the name
I have some questions about using MySQLi queries, and related memory management. Suppose I
Some questions about Android and Google Directions Service: Is there a native way on
I have some questions about interaction with Hibernate: Do I use openSession or getCurrentSession
Got some questions about the php date function.... Here it goes.. I use jquery's
There are already some questions about how to set a default file name for
I have some questions about basic CSS that I was unable to understand or

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.