public static void main(final String[] args) {
    DefaultSubLWorker.startProfiling();
    final int BASE_PORT = 3600;
    try {
      final CycAccess access = new CycAccess("localhost", BASE_PORT);
      SubLWorkerSynch worker = new DefaultSubLWorkerSynch("(+ 1 1)", access);
      Object work = worker.getWork();
      System.out.println("Got worker: " + worker + "\nGot result: " + work + ".");
      worker = new DefaultSubLWorkerSynch("(genls #$TransportationDevice)", access);
      work = worker.getWork();
      System.out.println("Got worker: " + worker + "\nGot result: " + work + ".");
      worker = new DefaultSubLWorkerSynch("(generate-phrase '(#$isa #$Brazil #$IndependentCountry))", access);
      work = worker.getWork();
      System.out.println("Got worker: " + worker + "\nGot result: " + work + ".");
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      final CycAccess access = new CycAccess("localhost", BASE_PORT);
      Thread workerThread = new Thread() {
        public void run() {
          try {
            System.out.println("Starting work.");
            testWorker = new DefaultSubLWorkerSynch("(do-assertions (a))", access);
            final Object obj = testWorker.getWork();
            System.out.println("Finished work with " + testWorker.getStatus().getName()
              + ", received: " + obj);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      };
      workerThread.start();
      Thread.currentThread().sleep(10000);
      System.out.println("About to cancel work.");
      testWorker.cancel();
      System.out.println("Canceled work.");
      
      System.out.println("\nGiving chance to get ready ....\n");
      Thread.currentThread().sleep(1000);

      System.out.println( "\nOk, second round ....\n\n");      
      workerThread = new Thread() {
        public void run() {
          try {
            System.out.println("Starting work.");
            testWorker = new DefaultSubLWorkerSynch("(do-assertions (a))", access);
            Object obj = testWorker.getWork();
            System.out.println("Finished work with " + testWorker.getStatus().getName()
              + ", received: " + obj);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      };
      workerThread.start();
      Thread.currentThread().sleep(10000);
      System.out.println("About to abort work.");
      testWorker.abort();
      System.out.println("Aborted work.");

      System.out.println("\nGiving chance to get ready ....\n");
      Thread.currentThread().sleep(1000);

      System.out.println( "\nOk, third round ....\n\n");
      workerThread = new Thread() {
        public void run() {
          long timeBefore = 0, timeAfter = 0;
          try {
            System.out.println("Starting work.");
            timeBefore = System.currentTimeMillis();
            testWorker = new DefaultSubLWorkerSynch("(do-assertions (a))", access, 500);
            Object obj = testWorker.getWork();
            timeAfter = System.currentTimeMillis();
            System.out.println("Finished work with " + testWorker.getStatus().getName()
              + " after " + (timeAfter - timeBefore) 
              + " millisecs (should be about 500), received: " + obj);
          } catch (Exception e) {
            timeAfter = System.currentTimeMillis();
            System.out.println( "The current time is: " + (timeAfter - timeBefore) 
              + " millisecs (should be about 500)");
            e.printStackTrace(); 
          }
        }
      };
      workerThread.start();
      Thread.currentThread().sleep(10000);
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      DefaultSubLWorker.endProfiling("/home/reed/subl-command-profile-report.txt");
    } catch (Exception e) {
      e.printStackTrace();
    }
    System.exit(0);
  }