AtomicBoolean interruptionRequest = new AtomicBoolean(false);
if (context != null && nt > 1) {
context = context.singleThreadVersion();
}
Lock lock = new ReentrantLock();
Condition condition = lock.newCondition();
for (int threadIndex = 0; threadIndex < tasks.length; threadIndex++) {
SliceProcessingTask task = new SliceProcessingTask(context, threadIndex, nt, lock, condition);
task.setProcessedData(dest, src, destBits, srcBits);
task.setRanges(range, numberOfRanges);
task.setSynchronizationVariables(readyLayers, interruptionRequest);