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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:57:04+00:00 2026-06-06T19:57:04+00:00

The Java Concurrency API gives you Executor and ExecutorService interfaces to build from, and

  • 0

The Java Concurrency API gives you Executor and ExecutorService interfaces to build from, and ships with several concrete implementations (ThreadPoolExecutor and ScheduledThreadPoolExecutor).

I’m completely new to Java Concurrency, and am having difficulty finding answers to several very-similarly-related questions. Rather than cluttering SO with all these tiny questions I decided to bundle them together, because there’s probably a way to answer them all in one fell swoop (probably because I’m not seeing the whole picture here):

  • Is it common practice to implement your own Executor/ExecutorService? In what cases would you do this instead of using the two concretions I mention above? In what cases are the two concretions preferable over something “homegrown”?
  • I don’t understand how all of the concurrent collections relate to Executors. For instance, does ThreadPoolExecutor use, say, ConcurrentLinkedQueue under the hood to queue up submitted tasks? Or are you (the API developer) supposed to select and use, say, ConcurrentLinkedQueue inside your parallelized run() method? Basicaly, are the concurrent collections there to be used internally by the Executors, or do you use them to help write non-blocking algorithms?
  • Can you configure which concurrent collections an Executor uses under the hood (to store submitted tasks), and is this common practice?

Thanks in advance!

  • 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-06T19:57:07+00:00Added an answer on June 6, 2026 at 7:57 pm

    Is it common practice to implement your own Executor/ExecutorService?

    No. I’ve never had to do this and I’ve been using the concurrency package for some time. The complexity of these classes and the performance implications around getting them “wrong” mean that you should really think carefully about it before undertaking such a project.

    The only time that I felt the need to implement my own executor service was when I wanted to implement a “self-run” executor service. That was until a friend showed me that there was a way to do it with a RejectedExecutionHandler.

    The only reason why I’d wanted to tweak the behavior of the ThreadPoolExecutor was to have it start all of the threads up to the max-threads and then stick the jobs into the queue. By default the ThreadPoolExecutor starts min-threads and then fills the queue before starting another thread. Not what I expect or want. But then I’d just be copying the code from the JDK and changing it — not implementing it from scratch.

    I don’t understand how all of the concurrent collections relate to Executors. For instance, does ThreadPoolExecutor use, say, ConcurrentLinkedQueue under the hood to queue up submitted tasks?

    If you are using one of the Executors helper methods then you don’t have to worry about this. If you are instantiating ThreadPoolExecutor yourself then you provide the BlockingQueue to use.

    public static ExecutorService newFixedThreadPool(int nThreads) {
        return new ThreadPoolExecutor(nThreads, nThreads,
               0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
    }
    

    Versus:

     ExecutorService threadPool = 
         new ThreadPoolExecutor(minThreads, maxThreads, 0L, TimeUnit.MILLISECONDS,
                new SynchronousQueue<Runnable>());
    

    Can you configure which concurrent collections an Executor uses under the hood (to store submitted tasks), and is this common practice?

    See the last answer.

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

Sidebar

Related Questions

From book Java Concurrency in Practice page 26: You can use volatile variables only
Java Concurrency in Practice gives the following example of an unsafe class which due
I am reading Java concurrency in practice and the below examples are from that.
Reading Java Concurrency In Practice, there's this part in section 3.5: public Holder holder;
I have read Java Concurrency in Practice and this is a great reference, but
Goetz's Java Concurrency in Practice , page 41, mentions how this reference can escape
I am reading Java Concurrency in practice and looking at the example code on
I am reading Java Concurrency in practice and looking at the example code on
When I read the java concurrency in practice c03, I was confused by the
I was reading some of the concurrency patterns in Brian Goetze's Java Concurrency in

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.