code: private void optimize(long fileLength) {
  
  		final int availableProcessors = Runtime.getRuntime().availableProcessors();
  
  		final long free = Runtime.getRuntime().freeMemory() / 2;
  
  		int workerSize = availableProcessors / 2;
  		if (workerSize < 2) {
  			workerSize = 2;
  		}
  
  		long bufferSize = free / workerSize;
  		if (bufferSize > 1 * 1024 * 1024) {
  			bufferSize = 1 * 1024 * 1024;
  		}
  
  		long blockSize = fileLength / workerSize;
  		if (blockSize > 1 * 1024 * 1024) {
  			blockSize = 1 * 1024 * 1024;
  		}
  		int iBlockSize = (int) blockSize;
  
  		if (bufferSize > blockSize) {
  			bufferSize = blockSize;
  		}
  		int iBufferSize = (int) bufferSize;
  
  		this.setBlockSize(iBlockSize);
  		this.setMaxNumOfThreads(workerSize);
  		this.setBufferSizePerWorker(iBufferSize);
  		this.setSubBufferSize(256);
  
  	}
docs: Optimize threading and memory
  
  @param fileLength