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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:35:43+00:00 2026-06-08T13:35:43+00:00

I have a Java application that is designed to run on removable devices. One

  • 0

I have a Java application that is designed to run on removable devices. One feature of it is that it is designed to list all of the folders on the drive, but obviously the more files and folders there are the more time it will take (regardless of how powerful the computer is) and with removal devices getting bigger and bigger these days, I think it is important to gain as much speed in this process as possible.

I know that the best/quickest (in terms of listing, not coding) way would be to create an index file, but I think that misses the point of what my application is all about. So, I thought maybe threads would help because in theory, even two would double the speed of listing, but I don’t know if this is possible, and if so how?

Any answers would be appreciated. Here is the recursive method that I currently have:

private static void recursiveNodeCreation(DefaultMutableTreeNode node, String root){
        if(root==null) root = RUNNING_DRIVE = ".";

        try{
        // Get a list of files/folders in the root directory
        File rootDir = new File(root);

        File[] files = rootDir.listFiles();
        // Loop through the files/folders
        for(File current : files){
            if(Files.isReadable(current.toPath()) && !current.isHidden() && current.isDirectory()){
                DefaultMutableTreeNode folder = new DefaultMutableTreeNode(new FolderOnDrive(current.getName(), current.getPath()));
                recursiveNodeCreation(folder, current.getPath());
                node.add(folder);
            }
        }
        }catch(Exception e){e.printStackTrace();}
}

(RUNNING_DRIVE holds the drive letter of the drive that the application is running on. I just added = "." to make it quicker whilst testing. As you may have guessed, I’m listing all the folders in a JTree.)

  • 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-08T13:35:44+00:00Added an answer on June 8, 2026 at 1:35 pm

    Threading an application will improve the speed of the application if multiple operations can be performed in parallel. For example, if you are reading and writing from a single network connection, it makes sense to fork a thread so that you can handle other connections at the same time.

    In your case, however, I suspect that you are being limited by your removable device’s ability to service IO requests. Every device (including memory) has a maximum number of requests and a maximum amount of data that it can handle in a time period — regardless of the number of threads. Memory sticks and the like are notoriously slow which is why many cameras have memory inside themselves to they can take a number of pictures quickly while writing to the SD card over time. Adding additional threads will most likely not improve the overall application performance and may actually slow it down because the IO requests will be working on different parts of the storage drive and competing with each other.

    One way to have your application seem more performant is to have one thread do the actual reading of the device in the background. Then your UI can show the initial results to the user (like the top directory) and fill in more information as the background thread reads in from the device.

    To test to see if you are IO bound, you should run your code on a faster hard drive to compare it’s directory recursion speed with the removable device.

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

Sidebar

Related Questions

I have a Java application that run as a background service, i.e. no GUI.
I have a java application that runs out of memory, but I have no
I have a long-lived server application that is designed to run with minimal downtime
I have a Java client - server application. The client is designed to run
Question I have an application written in Java. It is designed to run on
I have a java application that people can log into (and do various things
I have a Java application that makes heavy use of a large file, to
I have a Java application that is managed using Maven. The project involves the
I have a Java application that needs to collect and report a large number
I have a standalone java application that fires up several JMS consumers using 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.