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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:27:47+00:00 2026-05-22T03:27:47+00:00

Possible Duplicate: How many threads is too many? I have a large for loop,

  • 0

Possible Duplicate:
How many threads is too many?

I have a large for loop, in which I want each item to be passed to a function on a thread. I have a thread pool of a certain size, and I want to reuse the threads. What is the most efficient way to do this?

What would be the most efficient size for the thread pool? Or at least what is the best way to figure it out?

pthread_t thread_id[10];

int i;
for(i = 0; i < 10000000; i++) {
   pthread_create(thread_id[?], NULL, threadFunc, params[i]);
}
  • 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-22T03:27:47+00:00Added an answer on May 22, 2026 at 3:27 am

    Too few threads means wasted performance opportunity and too many threads wastes resources consumed by each thread and can reduce performance due to contention among threads. I would use measurements and see what number works the best. Just curious, is there are reason why you want each iteration to be a new thread?

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

Sidebar

Related Questions

Possible Duplicate: How many lines of code should a function/procedure/method have? I would like
Possible Duplicate: How many files in a directory is too many? I was told
Possible Duplicate: Multiprocessing launching too many instances of Python VM I am trying python
Possible Duplicate: Very large HTTP request vs many small requests I need a 2D
Possible Duplicate: Image resizing web service many web provider have support for php but
Possible Duplicate: how many characters can a Java string have? How many characters can
Possible Duplicate: Why does Guava's ImmutableList have so many overloaded of() methods? Looking at
Possible Duplicate: How to calculate how many years passed since a given date in
Possible Duplicate: Are @property(nonatomic)ivar @property(nonatomic,assign)ivar the same or different? i have seen in many
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the

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.