Last active
December 15, 2015 17:19
-
-
Save nowelium/5295747 to your computer and use it in GitHub Desktop.
This file contains 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
import java.io.File; | |
import java.io.FileOutputStream; | |
public class A { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/a"); | |
final FileOutputStream output = new FileOutputStream(file); | |
Thread th0 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
Thread th1 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
th0.start(); | |
th1.start(); | |
try { | |
Thread.sleep(1000L); | |
} catch(InterruptedException e){ | |
} | |
output.close(); | |
} | |
} |
This file contains 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
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.FileDescriptor; | |
public class B { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/b"); | |
final FileOutputStream output = new FileOutputStream(file); | |
final FileDescriptor fd = output.getFD(); | |
Thread th0 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
fd.sync(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
Thread th1 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
fd.sync(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
th0.start(); | |
th1.start(); | |
try { | |
Thread.sleep(100L); | |
} catch(InterruptedException e){ | |
} | |
output.close(); | |
} | |
} |
This file contains 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
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.FileDescriptor; | |
public class C { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/c"); | |
final FileOutputStream output = new FileOutputStream(file); | |
final FileDescriptor fd = output.getFD(); | |
Thread th0 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
output.flush(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
Thread th1 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
output.flush(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
th0.start(); | |
th1.start(); | |
try { | |
Thread.sleep(100L); | |
} catch(InterruptedException e){ | |
} | |
output.close(); | |
} | |
} |
This file contains 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
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.FileDescriptor; | |
public class D { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/d"); | |
final FileOutputStream output = new FileOutputStream(file); | |
final FileDescriptor fd = output.getFD(); | |
Thread th0 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
output.flush(); | |
fd.sync(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
Thread th1 = new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 100000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
output.flush(); | |
fd.sync(); | |
} | |
} catch(java.io.IOException e){} | |
} | |
}); | |
th0.start(); | |
th1.start(); | |
try { | |
Thread.sleep(100L); | |
} catch(InterruptedException e){ | |
} | |
output.close(); | |
} | |
} |
This file contains 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
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.FileDescriptor; | |
public class E { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/e"); | |
final FileOutputStream output = new FileOutputStream(file); | |
final FileDescriptor fd = output.getFD(); | |
new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 1000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
} | |
fd.sync(); | |
} catch(java.io.IOException e){} | |
} | |
}).start(); | |
new Thread(new Runnable(){ | |
public void run() { | |
try { | |
for(int i = 0; i < 1000; ++i){ | |
output.write(Integer.toString(i).concat("\n").getBytes()); | |
} | |
fd.sync(); | |
} catch(java.io.IOException e){} | |
} | |
}).start(); | |
new Thread(new Runnable(){ | |
public void run() { | |
try { | |
Thread.sleep(100L); | |
output.close(); | |
} catch(Exception e){} | |
} | |
}).start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment