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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:21:34+00:00 2026-05-27T05:21:34+00:00

I am doing coding to solve a problem like this. There are about 50

  • 0

I am doing coding to solve a problem like this.
There are about 50 – 200 small files. And total size of these files will not be very big. And my goal is concurrently loading them into one table.

And it seems the code works quite well and it really works faster than using single thread.

However, I just a bit not sure. Is it the best choice to open as much as threads as the file numbers?

Another thing is I just use the simplest way to do the multi-thread.
Is this also the best choice?

Any suggestion or advice is appreciated!

 for (int i = 0; i < threads.length; ++i) {
                        synchronized (threads[i]) {
                            threads[i].run();
                        }
                    }
                    for (int i = 0; i < threads.length; ++i) {
                        synchronized (threads[i]) {
                            try {
                                threads[i].join();
                            } catch (InterruptedException e1) {
                                 return;
                            }
                        }
                    }
  • 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-27T05:21:35+00:00Added an answer on May 27, 2026 at 5:21 am

    First thing: Threads are started with start(), not run(). run() will make them run serially on the main thread.

    Second thing: It’s pointless to start 200 threads. You are only wasting time and system resources without getting any speedup (you cannot be faster by a factor larger than the number of processor cores). Just use an ExecutorService and queue up tasks using submit. This managed thread pool will take care of selecting the correct number of threads depending on your system resources.

    Third thing: If you are just processing some files independently, you do not need any locks. Especially in your example you are using locks to start and join threads, which has no (positive) effect.

    Edit: Probably the best solution in your case is to just implement a single-producer (to read from disk), multiple-consumer (to process the files) system.

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

Sidebar

Related Questions

I'm doing a bit of coding, where I have to write this sort of
I have decided to start doing small coding projects on my own that focus
For some time I am battling to solve this problem but I am not
for a project for school I have decided to solve a problem by coding
I'm doing some coding in JSP/Java (without any framework, or other strange things) and
I might be doing a coding competition soon, I was wondering if anyone made
I'm planning on doing more coding from home but in order to do so,
some code snippets. The java coding doing the jaxb unmarshaling. pretty straightforward, copied out
I'm doing some maintenance coding on a webapp and I am getting a javascript
I'm doing some JAVA coding at home and at work. At home i 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.