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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:31:36+00:00 2026-06-12T21:31:36+00:00

When I create ExecutorService with below code in JAVA,can someone explain how the ExecutorService

  • 0

When I create ExecutorService with below code in JAVA,can someone explain how the ExecutorService works ?

ExecutorService executor = Executors.newFixedThreadPool(400);

    for (int i = 0; i < 500; i++) {
        Runnable worker = new MyRunnable(10000000L + i);
        executor.execute(worker);
    }

I believe that there will be a single Queue of work and my for loop will add 500 Runnable tasks to this queue. Now the ExecutorService has been created with a Thread Pool of 400 threads.

So of those 500 tasks in the queue, the 400 threads in the ExecutorService will execute this 400 tasks at a time, and the remaining as slots are freed up?

Am I correct in my understanding ?

  • 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-12T21:31:37+00:00Added an answer on June 12, 2026 at 9:31 pm

    JavaDoc newFixedThreadPool

    Creates a thread pool that reuses a fixed number of threads operating
    off a shared unbounded queue. At any point, at most nThreads threads
    will be active processing tasks. If additional tasks are submitted
    when all threads are active, they will wait in the queue until a
    thread is available.
    If any thread terminates due to a failure during
    execution prior to shutdown, a new one will take its place if needed
    to execute subsequent tasks. The threads in the pool will exist until
    it is explicitly shutdown.

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

Sidebar

Related Questions

I create a ThreadPoolExecutor with this line of code : private ExecutorService executor =
I use an ExecutorService to execute a task. This task can recursively create other
I'm trying to create a ThreadPoolExecutor: // Thingy implements Delayed and Runnable ExecutorService executor
I write application in Java using ThreadPool. Firstly I create new ThreadPool: private ExecutorService
CREATE TABLE `tbl_atn` ( `atn_id` int(15) NOT NULL AUTO_INCREMENT, `eng_id` int(15) DEFAULT NULL, `visit`
Create Proc CrearNuevoAnuncio @Titulo varchar(250), @Precio int, @Descripcion varchar(250), @IDCategoria int, @IDImagen int, @Login
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
CREATE TABLE #Report( Cell int, CellValue double) Error here DECLARE @Report TABLE ( Cell
create table snippet( id int not null auto_increment, primary key(id), idlanguage int not null,
I created multiple ExecutorService instances in my code, usually each UI page has one

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.