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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:37:19+00:00 2026-05-27T22:37:19+00:00

In my program I have a while loop which iterates through an array list

  • 0

In my program I have a while loop which iterates through an array list of a bunch of pictures and does a bunch of processing on them to change how they look and their image type and then writes them to the disk. My question is would adding multiple threads to process images or save the images speed things up, if so what would be the best way to go about it.
ArrayList images = new ArrayList ();//over 500 images
ArrayList paths = new ArrayList ();
int len = images.size();

for (int i =0; i < len ; i ++)
{
BufferedImage image  = process (images.get(i))//takes about a second 
ImageIO.write(image, "jpg", new File(getImagePaths().get(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-27T22:37:20+00:00Added an answer on May 27, 2026 at 10:37 pm

    You could partition your list into n blocks so that you have blocks of size of list / n, and you could then have n threads operate on these “blocks” of images. This way you have more work that can be done concurrently.

    To address some things brought up, it would most likely increase I/O concurrency as well because in a single threaded run it would fault on the first miss and block, then fault again to read the 2nd image, etc… In the multi threaded way it would block for n images at a time which allows the I/O scheduler to handle more I/O at a time (which is generally a good thing). This would mean increased performance even in single core processors due to the overlapping of I/O and the availability of more threads to run on the core while the blocked for I/O threads wait.

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

Sidebar

Related Questions

So I have a Linux program that runs in a while(true) loop, which waits
I have a while loop in C program which was supposed to wait for
In my main thread I have a while(listening) loop which calls accept() on my
I have a C++ program which is mainly used for video processing. Inside the
I have written a multithreaded program which does some thinking and prints out some
I have two simple while loops in my program that I feel ought to
I have program that has a variable that should never change. However, somehow, it
I have a Main Program which is running a script on the target device(smart
So I have a python script that runs a loop in which it calls
I am trying to program a game in which I have a Table class

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.