use of cbit.vcell.resource.StdoutSessionLogConcurrent.LifeSignInfo in project vcell by virtualcell.
the class StdSessionLogTest method setup.
@SuppressWarnings("resource")
private static void setup(String[] args) throws Exception {
Logging.init();
PrintStream output = new PrintStream(args[3]);
SessionLog log = null;
String type = args[0];
if (type.equals("reg")) {
log = new StdoutSessionLog("stdlog", output);
if (TEST_STD_OUT) {
PrintStream ps = new PrintStream(new FileOutputStream("console.txt"), true);
System.setOut(ps);
}
} else if (type.equals("con")) {
StdoutSessionLogConcurrent a = new StdoutSessionLogConcurrent("conlog", output, new LifeSignInfo());
if (TEST_STD_OUT) {
PrintStream ad = a.printStreamFacade();
System.setOut(ad);
System.out.print("h");
}
log = a;
} else {
showUsage();
return;
}
final int nThreads = Integer.parseInt(args[1]);
final int nSeconds = Integer.parseInt(args[2]);
Thread[] babblers = new Thread[nThreads];
if (args.length > 4) {
final long milliWait = Long.parseLong(args[4]);
for (int t = 0; t < nThreads; t++) {
babblers[t] = new BabblerWait(log, t, milliWait);
}
} else {
for (int t = 0; t < nThreads; t++) {
babblers[t] = new Babbler(log, t);
}
}
for (int t = 0; t < nThreads; t++) {
babblers[t].start();
}
System.err.println("Sleeping " + nSeconds);
Thread.sleep(1000 * nSeconds);
log.print("exiting main");
System.err.println("End of sleep");
}
Aggregations