1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
// An output-only test for JSwat.
// $Author: nfiedler $ $Date: 2002-10-13 00:03:33 -0700 (Sun, 13 Oct 2002) $ $Rev: 604 $
import java.io.*;
public class output {
protected static void printStuff(int sleepLen, int numLoops) {
try {
for (int i = 0; i < numLoops; i++) {
System.out.println("out 1");
Thread.sleep((long) (Math.random() * sleepLen));
System.err.println("err 1");
Thread.sleep((long) (Math.random() * sleepLen));
System.out.println("out 2");
Thread.sleep((long) (Math.random() * sleepLen));
System.err.println("err 2");
Thread.sleep((long) (Math.random() * sleepLen));
System.out.println("out 3");
Thread.sleep((long) (Math.random() * sleepLen));
System.err.println("err 3");
Thread.sleep((long) (Math.random() * sleepLen));
System.out.println("out 4");
Thread.sleep((long) (Math.random() * sleepLen));
System.err.println("err 4");
}
} catch (InterruptedException ie) {
// yeah, like that'll ever happen
ie.printStackTrace();
}
}
public static void main(String[] args) {
int sleepLen = 2000;
int numLoops = 10;
if (args.length > 0) {
try {
sleepLen = Integer.parseInt(args[0]);
} catch (NumberFormatException nfe) {
System.err.println("First argument must be an integer!");
System.exit(1);
}
if (args.length > 1) {
try {
numLoops = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
System.err.println("Second argument must be an integer!");
System.exit(1);
}
}
}
printStuff(sleepLen, numLoops);
}
}
|