Create a new BabySitter and make sure it reads the initial children list.
Use the provided ExecutorService to queue events to, rather than
creating a private ExecutorService.
497852
public static BabySitter nonblockingFactory(ZooKeeper zk, String dir,
                                                Callback cb, ExecutorService es)
        throws InterruptedException, ExecutionException
    {
        BabySitter bs = new BabySitter(zk, dir, cb, es);
        bs.m_es.submit(bs.m_eventHandler);
        return bs;
    }
1055944
private B newProcessBuilder(Class[] param_types, Object[] params)
    {
        if (process_builder_class != null)
        {
            try
            {
                Constructor<B> constructor = process_builder_class.getDeclaredConstructor(param_types);
                return constructor.newInstance(params);
            }
            catch (Exception e)
            {
                throw new QueujException(e);
            }
        }

        if (parent_queue != null)
            return (B)parent_queue.newProcessBuilder(param_types, params);

        // else
        throw new QueujException("No ProcessBuilder exists for Queue");
    }
1028334
public Queue<B> newQueue()
    {
        return new Queue<B>(parent_queue, queue_restriction, index, process_builder_class, process_server_class,
            default_occurence, default_visibility, default_access, default_resilience, default_output, implementation_options);
    }
656196
public KafkaMsgConsumer setExecutorService(ExecutorService executorService) {
        if (this.executorService != null) {
            this.executorService.shutdown();
        }
        this.executorService = executorService;
        myOwnExecutorService = false;
        return this;
    }
68190
public static ListeningExecutorService executor() {
        final ExecutorService svc = Executors.newCachedThreadPool(MoreExecutors.platformThreadFactory());
        return MoreExecutors.listeningDecorator(svc);
    }
290399
function makeChildrenObserver(e) {
  function add    (v)                   { e.appendChild(v); }
  function _delete(v, i, o, {oldValue}) { e.removeChild(oldValue); }
  function update (v, i, c, {oldValue}) {
    if (i !== 'length') { e.replaceChild(v, oldValue); }
  }
  return makeObserver({add, update, delete: _delete});
}
596255
def spawn(self, **kwargs):
        ''''''
        copy = dict(self.kwargs)
        copy.update(kwargs)
        # Apparently there's an issue with importing gevent in the parent
        # process and then using it int he child. This is meant to relieve that
        # problem by allowing `klass` to be specified as a string.
        if isinstance(self.klass, string_types):
            self.klass = util.import_class(self.klass)
        return self.klass(self.queues, self.client, **copy)
788555
protected static ExecutorService createDefaultExecutor(Args options) {
    return (options.workerThreads > 0) ? Executors.newFixedThreadPool(options.workerThreads) : null;
  }
278676
@Bean(EXECUTOR_SERVICE_BEAN_NAME)
    public ExecutorService executorService() {
        if (this.properties.getNumberOfThread() == 0) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Use cached thread pool.");
            }
            return Executors.newCachedThreadPool();
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Use {} fixed thread pool.", this.properties.getNumberOfThread());
        }
        return Executors.newFixedThreadPool(this.properties.getNumberOfThread());
    }
728974
public ExecutionImpl createExecution(boolean initializeExecutionStartContext) {
    // create the new child execution
    ExecutionImpl createdExecution = newExecution();

    // initialize sequence counter
    createdExecution.setSequenceCounter(getSequenceCounter());

    // manage the bidirectional parent-child relation
    createdExecution.setParent(this);

    // initialize the new execution
    createdExecution.setProcessDefinition(getProcessDefinition());
    createdExecution.setProcessInstance(getProcessInstance());
    createdExecution.setActivity(getActivity());

    // make created execution start in same activity instance
    createdExecution.activityInstanceId = activityInstanceId;

    // with the fix of CAM-9249 we presume that the parent and the child have the same startContext
    if (initializeExecutionStartContext) {
      createdExecution.setStartContext(new ExecutionStartContext());
    } else if (startContext != null) {
      createdExecution.setStartContext(startContext);
    }

    createdExecution.skipCustomListeners = this.skipCustomListeners;
    createdExecution.skipIoMapping = this.skipIoMapping;

    return createdExecution;
  }
1261366
private FutureRequestExecutionService buildRequestExecutorService(final CloseableHttpClient httpClient) {
        if (this.executorService == null) {
            this.executorService = new ThreadPoolExecutor(this.threadsNumber, this.threadsNumber, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(this.queueSize));
        }
        return new FutureRequestExecutionService(httpClient, this.executorService);
    }
298914
@Override
    public void     start() throws Exception
    {
        if ( !state.compareAndSet(State.LATENT, State.STARTED) )
        {
            throw new IllegalStateException();
        }

        try
        {
            client.create().creatingParentContainersIfNeeded().forPath(queuePath);
        }
        catch ( KeeperException.NodeExistsException ignore )
        {
            // this is OK
        }
        if ( lockPath != null )
        {
            try
            {
                client.create().creatingParentContainersIfNeeded().forPath(lockPath);
            }
            catch ( KeeperException.NodeExistsException ignore )
            {
                // this is OK
            }
        }

        if ( !isProducerOnly || (maxItems != QueueBuilder.NOT_SET) )
        {
            childrenCache.start();
        }

        if ( !isProducerOnly )
        {
            service.submit
                (
                    new Callable<Object>()
                    {
                        @Override
                        public Object call()
                        {
                            runLoop();
                            return null;
                        }
                    }
                );
        }
    }
1309893
@Override
	public QueueSender createSender(Queue queue) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        
	        RemoteQueueSender sender =  new RemoteQueueSender(this,
	                                                          DestinationTools.asRef(queue),
	                                                          idProvider.createID());
	        registerProducer(sender);
	        return sender;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
1254060
private void init() throws IOException {
        if (initialized.compareAndSet(false, true)) {
            log.debug("Init: {}", mode);
            // instance an executor for queue handling
            scheduledExecutorService = Executors.newScheduledThreadPool(schedulerThreadSize, new CustomizableThreadFactory("FileConsumerExecutor-"));
            // if the path is null, the consumer has been uninitialized
            if (path != null) {
                if (log.isDebugEnabled()) {
                    Path parent = path.getParent();
                    log.debug("Parent abs: {} dir: {}", parent.isAbsolute(), Files.isDirectory(parent));
                }
                if (IClientStream.MODE_APPEND.equals(mode)) {
                    if (Files.notExists(path)) {
                        throw new IOException("File to be appended doesnt exist, verify the record mode");
                    }
                    log.debug("Path: {}\nRead: {} write: {} size: {}", path, Files.isReadable(path), Files.isWritable(path), Files.size(path));
                    writer = new FLVWriter(path, true);
                } else if (IClientStream.MODE_RECORD.equals(mode)) {
                    try {
                        // delete existing file
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                        // ensure parent dirs exist
                        Files.createDirectories(path.getParent());
                        // create the file
                        path = Files.createFile(path);
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                    if (!Files.isWritable(path)) {
                        throw new IOException("File is not writable");
                    }
                    log.debug("Path: {}\nRead: {} write: {}", path, Files.isReadable(path), Files.isWritable(path));
                    writer = new FLVWriter(path, false);
                    if (audioConfigurationTag != null) {
                        writer.writeTag(audioConfigurationTag);
                    }
                    if (videoConfigurationTag != null) {
                        writer.writeTag(videoConfigurationTag);
                        gotVideoKeyframe = true;
                    }
                } else {
                    //throw new IllegalStateException(String.format("Illegal mode type: %s", mode));
                    try {
                        // delete existing file since we're not recording nor appending
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                }
            } else {
                log.warn("Consumer is uninitialized");
            }
            log.debug("Init - complete");
        }
    }
1051543
def addChild(self, childJob):
        
        self._children.append(childJob)
        childJob._addPredecessor(self)
        return childJob
1136744
function addExecutor(name, executor) {
  if (this._executors[name]) throw new Error('executor "' + name + '" is already defined');
  this._executors[name] = executor;
}
610164
@Override
	protected Statement childrenInvoker(final RunNotifier notifier) {
		return new Statement() {
			@Override
			public void evaluate() {
				JUnitScenarioReporter junitReporter = new JUnitScenarioReporter(
				notifier, numberOfTestCases, rootDescription, configuration.keywords());
				// tell the reporter how to handle pending steps
				junitReporter.usePendingStepStrategy(configuration
						.pendingStepStrategy());

				addToStoryReporterFormats(junitReporter);

				configurableEmbedder.run();
			}
		};
	}