Created
September 23, 2014 23:03
-
-
Save camerondavison/448eb429c2c4c20f557f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Semaphore s = new Semaphore(10); | |
final Stopwatch w = Stopwatch.createStarted(); | |
final File t = Files.createTempDir(); | |
try { | |
for (int i = 0; i < 10000; i++) { | |
s.acquire(); | |
final RandomAccessFile file = new RandomAccessFile(new File(t, "f" + i + ".txt"), "rw"); | |
file.write("HELLO WORLD".getBytes(Charsets.UTF_8)); | |
file.close(); | |
s.release(); | |
} | |
w.stop(); | |
System.out.println("Done in " + w); | |
} finally { | |
for (File file : Files.fileTreeTraverser().breadthFirstTraversal(t)) { | |
file.delete(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment