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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:06:19+00:00 2026-06-01T16:06:19+00:00

I am creating a threadpool and since I don’t need any output from my

  • 0

I am creating a threadpool and since I don’t need any output from my threads, I am not using Futures&Callables. But the problem is that if I don’t use Futures, I am seeing that threadpool is loosing tasks that I am submitting.

Here is my code structure which is loosing tasks-

while(hasWorkToDo){
ThreadPoolExecutor.execute(new Worker());
System.out.println("Work submitted");
}

Within Worker(), I am printing “got work” at the very first line of run() implementation.

When I run above code the number of “got work” is always less than “Work submitted”.

But, when I change my code structure to below-

ArrayList<Future<String>> list = new ArrayList<Future<String>>();
while(hasWorkToDo){
Future<String> submit=ThreadPoolExecutor.submit(new Worker());
list.add(submit) 
}

for (Future<String> f : list) {
f.get();
}

I then see that number of times “got work” is equal to “Work submitted”

This leads me to believe that unless I am using Futures&Callables, the threadpool is using tasks that I am submitting.

Have you seen such behavior before? Is there a better way to debug this?

  • 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-01T16:06:20+00:00Added an answer on June 1, 2026 at 4:06 pm

    You con’t need to keep the Future tasks, less you need to wait for them to complete before shutting down the executor. I suspect you are using shutdownNow() somewhere. Try using shutdown() instead.

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

Sidebar

Related Questions

I am not using any thread pool. Just creating ThreadArray.The for loop creats the
Creating a table without tbody using javascript createElement/appendChild will not add tbody in Firebug
Does anyone have any good resources that show creating an unlimited number of threads
In Asp.Net for creating a huge pdf report iam using ThreadPool.QueueUserWorkItem, My requirement is
I'm currently reading a java concurrency tutorial in http://tutorials.jenkov.com/java-concurrency/creating-and-starting-threads.html I could not understand what
I have an ASP.NET MVC 3 application. I'm using AsyncController and creating new threads.
I am working on creating a threadpool from scratch as part of an assignment
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
Creating a simple RPG game, first time using XNA. Trying to get my character
Creating an installer for possible remote systems so that if they do not have

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.