Search in sources :

Example 1 with LifeSignInfo

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");
}
Also used : PrintStream(java.io.PrintStream) SessionLog(org.vcell.util.SessionLog) LifeSignInfo(cbit.vcell.resource.StdoutSessionLogConcurrent.LifeSignInfo) FileOutputStream(java.io.FileOutputStream)

Aggregations

LifeSignInfo (cbit.vcell.resource.StdoutSessionLogConcurrent.LifeSignInfo)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 SessionLog (org.vcell.util.SessionLog)1