public static final void main(String[] args){
  try {
    Properties properties=new Properties();
    File journal=File.createTempFile("bigdata",".jnl");
    log.info(journal.getAbsolutePath());
    journal.deleteOnExit();
    properties.setProperty(BigdataSail.Options.FILE,journal.getAbsolutePath());
    BigdataSail sail=new BigdataSail(properties);
    BigdataSailRepository repo=new BigdataSailRepository(sail);
    repo.initialize();
    BigdataWriter writer=new BigdataWriter(repo);
    Collection<BigdataReader> readers=new LinkedList<BigdataReader>();
    for (int i=0; i < numReaders; i++) {
      readers.add(new BigdataReader(repo));
    }
    ExecutorService executor=Executors.newCachedThreadPool();
    Future writerFuture=executor.submit(writer);
    Collection<Future> readerFutures=new LinkedList<Future>();
    for (    BigdataReader reader : readers) {
      readerFutures.add(executor.submit(reader));
    }
    writerFuture.get();
    for (    BigdataReader reader : readers) {
      reader.kill();
    }
    for (    Future readerFuture : readerFutures) {
      readerFuture.get();
    }
    repo.shutDown();
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
}

public static final void main ( String [ ] args ) { try { Properties properties = new Properties ( ) ; File journal = File . createTempFile ( "bigdata" , ".jnl" ) ; log . info ( journal . getAbsolutePath ( ) ) ; journal . deleteOnExit ( ) ; properties . setProperty ( BigdataSail . Options . FILE , journal . getAbsolutePath ( ) ) ; BigdataSail sail = new BigdataSail ( properties ) ; BigdataSailRepository repo = new BigdataSailRepository ( sail ) ; repo . initialize ( ) ; BigdataWriter writer = new BigdataWriter ( repo ) ; Collection < BigdataReader > readers = new LinkedList < BigdataReader > ( ) ; for ( int i = 0 ; i < numReaders ; i ++ ) { readers . add ( new BigdataReader ( repo ) ) ; } ExecutorService executor = Executors . newCachedThreadPool ( ) ; Future writerFuture = executor . submit ( writer ) ; Collection < Future > readerFutures = new LinkedList < Future > ( ) ; for ( BigdataReader reader : readers ) { readerFutures . add ( executor . submit ( reader ) ) ; } writerFuture . get ( ) ; for ( BigdataReader reader : readers ) { reader . kill ( ) ; } for ( Future readerFuture : readerFutures ) { readerFuture . get ( ) ; } repo . shutDown ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } }
manage the control flow of the program . open a bigdata repository , kick off the writer , kick off the readers , wait for the writer to complete , kill the readers , wait for the readers to complete , shutdown the repository .
