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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:20:33+00:00 2026-05-24T07:20:33+00:00

After experiencing issues with mkdirs() and poking around the interwebs, I get the impression

  • 0

After experiencing issues with mkdirs() and poking around the interwebs, I get the impression that there are thread safety issues with mkdirs().

Is there a way to ensure the directories are properly created when it is possible that multiple threads might be trying to create similar file structures?

Thanks

(In my case I will be using this on Android)

  • 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-24T07:20:34+00:00Added an answer on May 24, 2026 at 7:20 am

    Okay, I know this has been inactive for a while, but I thought perhaps there was a simple solution. The article you linked in the comments on the question seems to indicate that the only problem is directories not being created. The solution there was to do this:

    if (!f.mkdirs()) {
        f.mkdirs();
    }
    

    However, that seems inefficient and can still have problems. So, why not simply do this:

    while (!f.mkdirs()) {}
    

    Simple, but it works.

    EDIT: After thinking a bit, that example may lag to oblivion and could cause thread lock. So, this might be a better idea:

    while (!f.mkdirs()) { Thread.yield(); }
    

    Of course, that would only be recommended if you’re in a thread that could cause thread lock, and as long as it’s not a high-priority situation. Just putting this out there.

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

Sidebar

Related Questions

After experiencing some performances issues on my client side, we decided to give a
After experiencing numerous problems with a certain media player, it got me thinking is
After installing rails3, I'm experiencing problems when trying to use haml with it. I
After being told by at least 10 people on SO that version control was
After lots of attempts and search I have never found a satisfactory way to
I'm experiencing a weird scrollbar issue. I'm building a page that uses jQuery and
Within my company we're working with NLog. We're experiencing issues with large amount of
I'm experiencing some different behavior after switching from ASP.NET MVC 1.0 to ASP.NET MVC
Recently (after installing Windows 7?) I have been experiencing problems when blaming files with
I am experiencing a problem with android emulator as described @ https://stackoverflow.com/questions/3986202/exception-after-starting-emulator-ddms-null Can someone

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.