question: public static boolean mkdirsWithRetry ( final File f ) { if ( f . exists ( ) ) { return f . isDirectory ( ) ; } for ( int i = 0 ; i < 10 && ! f . isDirectory ( ) ; ++ i ) { f . mkdirs ( ) ; } return f . isDirectory ( ) ; }
target:  A thread-safer mkdirs. mkdirs() will fail if another thread creates one of the directories it means to create before it does. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4742723 This attempts the mkdirs() multiple times, so that if another thread does create one of the directories, the next call to mkdirs() will take that into account. Note: this returns true iff the file f ends up being a directory, contrary to mkdirs(), which returns false if it existed before the call.