RenderRGBWaveTask[] tasks = makeRndTasks(planeDef, renderedDataBuf); performanceStats.startRendering(); int n = tasks.length; Future[] rndTskFutures = new Future[n]; ExecutorService processor = Executors.newCachedThreadPool(); while (0 < --n) rndTskFutures[n] = processor.submit(tasks[n]); if (n == 0) tasks[0].call();   processor.shutdown(); for (n = 1; n < rndTskFutures.length; ++n) { try { rndTskFutures[n].get(); } catch (Exception e) { if (e instanceof QuantizationException) throw (QuantizationException) e; throw (RuntimeException) e;  } } performanceStats.endRendering();   return renderedDataBuf; }
render(buf, planeDef); return buf; }
    RGBBuffer render(Renderer ctx, PlaneDef planeDef)		throws IOException, QuantizationException	{		//Set the rendering context for the current invocation.		renderer = ctx;        RenderingStats performanceStats = renderer.getStats();						//Initialize sizeX1 and sizeX2 according to the plane definition and		//create the RGB buffer.		initAxesSize(planeDef, renderer.getMetadata());        performanceStats.startMalloc();        RGBBuffer renderedDataBuf = new RGBBuffer(sizeX1, sizeX2);        performanceStats.endMalloc();                //Process each active wavelength.  If their number N > 1, then         //process N-1 async and one in the current thread.  If N = 1,         //just use the current thread.        RenderRGBWaveTask[] tasks = makeRndTasks(planeDef, renderedDataBuf);        performanceStats.startRendering();        int n = tasks.length;        Future[] rndTskFutures = new Future[n];  //[0] unused.        ExecutorService processor = Executors.newCachedThreadPool();//FIXME fast enough?        while (0 < --n)            rndTskFutures[n] = processor.submit(tasks[n]);        if (n == 0)            tasks[0].call();                 //Wait for all forked tasks (if any) to complete.        processor.shutdown();        for (n = 1; n < rndTskFutures.length; ++n) {            try {                rndTskFutures[n].get();            } catch (Exception e) {                if (e instanceof QuantizationException)                    throw (QuantizationException) e;                throw (RuntimeException) e;                  //B/c call() only throws QuantizationException, it must be RE.            }        }        performanceStats.endRendering();				//Done.		return renderedDataBuf;	}