Queue a thumbnail task in a global thumbnail thread.

@param callback Callback
330951
public synchronized static Task queue(Listener callback) {
    final Task task = new Task(callback);
    // TODO: synchronization?
    if(THREAD != null && THREAD.isAlive()) {
      THREAD.queue.add(task);
      return task;
    }
    THREAD = new ThumbnailThread();
    THREAD.queue.add(task);
    THREAD.start();
    return task;
  }
403766
private static Runnable asRunnable(final ClientTransport.PingCallback callback,
                                     final Throwable failureCause) {
    return new Runnable() {
      @Override
      public void run() {
        callback.onFailure(failureCause);
      }
    };
  }
1137678
public synchronized void attachAndEnqueueIfNotRun(@NonNull DownloadTask task,
                                                      @NonNull DownloadListener listener) {
        attachListener(task, listener);

        if (!isTaskPendingOrRunning(task)) {
            task.enqueue(hostListener);
        }
    }
1216558
def _threaded_callback(callback, *args):
    
    t = Thread(target=callback, args=args)
    t.daemon = True
    t.start()
552359
function nextTickFn() {
  // setImmediate allows to run task after already queued I/O callbacks
  if (typeof setImmediate === 'function') {
    return setImmediate;
  } else if (typeof process !== 'undefined' && process.nextTick) {
    return function(fn) {
      process.nextTick(fn);
    }
  } else {
    return function(fn) {
      setTimeout(fn, 0);
    }
  }
}
118122
void handlerProcessTask(Task task) {
		assertDispatcherThread();
		
		SerialTaskQueue taskQueue = mQueuesMap.get(task.subscriberCallback.queue);
		if (taskQueue == null) {
			taskQueue = new SerialTaskQueue(task.subscriberCallback.queue);
			mQueuesMap.put(task.subscriberCallback.queue, taskQueue);
			mQueuesList.add(taskQueue);
		}
		taskQueue.offer(task);

		processNextTask();
	}
458915
public synchronized void sendRetry(long retry, EventCallback callback) {

        if (open == 0 || shutdown) {
            if (callback != null) {
                callback.failed(this, null, null, null, new ClosedChannelException());
            }
            return;
        }
        queue.add(new SSEData(retry, callback));
        sink.getIoThread().execute(new Runnable() {
            @Override
            public void run() {
                synchronized (ServerSentEventConnection.this) {
                    if (pooled == null) {
                        fillBuffer();
                        writeListener.handleEvent(sink);
                    }
                }
            }
        });
    }
50443
private <T> ForkJoinTask<T> externalSubmit(ForkJoinTask<T> task) {
        Thread t; ForkJoinWorkerThread w; WorkQueue q;
        if (task == null)
            throw new NullPointerException();
        if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) &&
            (w = (ForkJoinWorkerThread)t).pool == this &&
            (q = w.workQueue) != null)
            q.push(task);
        else
            externalPush(task);
        return task;
    }
289514
public void addCallback(final ClientTransport.PingCallback callback, Executor executor) {
    Runnable runnable;
    synchronized (this) {
      if (!completed) {
        callbacks.put(callback, executor);
        return;
      }
      // otherwise, invoke callback immediately (but not while holding lock)
      runnable = this.failureCause != null ? asRunnable(callback, failureCause)
                                           : asRunnable(callback, roundTripTimeNanos);
    }
    doExecute(executor, runnable);
  }
21529
void imageLoaded() throws IOException {
    for (Future<Void> task : cachingTasks) {
      try {
        task.get();
      } catch (InterruptedException e) {
        throw new IOException("FSDirectory cache received interruption");
      } catch (ExecutionException e) {
        throw new IOException(e);
      }
    }
    
    // will not be used after startup
    this.cachingTasks = null;
    this.cachingExecutor.shutdownNow();
    this.cachingExecutor = null;
    
    // process remaining inodes
    for(INode inode : cachingTempQueue) {
      cacheNameInternal(inode);
    }
    this.cachingTempQueue = null;
    
    this.imageLoaded = true;
  }
785067
protected void threadBegin() {
        //
        // Note the 'beforeCallbacks' list is not going to have a well-defined order, so it is of limited use.
        // We probably want to revisit this with some kind of priority/order based on ranking to make
        // it more useful.
        //
        // At the moment we treat the setting of the tran timeout separately, rather than as a IJobExecutionStartCallbackService,
        // to reflect the fact that this is provided by a required dependency.  If we were to want this to function in SE mode,
        // say, we might want to factor this too as an "extension" that is provided by another layer, and so incorporate this into a
        // more generic, extensible "before" processing.
        try {
            tranMgr.setTransactionTimeout(0);
            if (beforeCallbacks != null) {
                for (IJobExecutionStartCallbackService callback : beforeCallbacks) {
                    if (logger.isLoggable(Level.FINER)) {
                        logger.logp(Level.FINER, CLASSNAME, "threadBegin", "Calling before callback", callback);
                    }
                    callback.jobStarted(runtimeWorkUnitExecution);
                }
            }
        } catch (Throwable t) {
            // Fail the execution if any of our before-work-unit callbacks failed. E.g. the joblog context setup
            // was unsuccessful. We may want to make it an option whether or not to fail here in the future.
            runtimeWorkUnitExecution.logExecutionFailedMessage();
            throw new BatchContainerRuntimeException("An error occurred during thread initialization.", t);
        }
    }
121157
function(callback) {
                //We want it once for the object path.
                e.once('cp#complete', function(err, destination, method) {
                    if (err) {
                        console.error(err.stack)
                    }
                    console.debug('cp() completed copy to: ', method);
                    callback(err, destination, method)
                })
            }
629340
public void enqueue(@Nullable final Callback<T> callback) {
    checkIfExecuted();
    this.callback.set(callback);
    dispatcher.execute(new Runnable() {
      @Override public void run() {
        T result;
        try {
          result = perform();
        } catch (Exception e) {
          notifyFailure(new ApolloException("Failed to perform store operation", e));
          return;
        }

        notifySuccess(result);
      }
    });
  }
1168910
public void callback(final Callback callback)
    {
        Runnable runnable = new Runnable()
        {
            @Override
            public void run()
            {
                try
                {
                    callback.result(queryId, awaitResult());
                }
                catch (Exception e)
                {
                    callback.error(queryId, e);
                }
            }
        };
        EXECUTOR_SERVICE.submit(runnable);
    }
356591
function queue(args) {
    args.push(resultsCallback);
    stack.push({caller: this.caller, args: args});
  }
232268
function(callback) {
      var firstThumbnail;

      for (var i = 0; i < thumbnailsPaths.length; i++) {
        var thumbnailsPath = thumbnailsPaths[i].thumbnailPath;

        if (!firstThumbnail)
          firstThumbnail = gm(thumbnailsPath);
        else
          firstThumbnail.append(thumbnailsPath, horizontally);

        images.push({
          sprite: destinationPath,
          image: thumbnailsPaths[i].originalPath,
          x: horizontally ? width * i : 0,
          y: horizontally ? 0 : height * i
        });
      }
      firstThumbnail
        .quality(quality)
        .write(destinationPath, callback);
    }
897139
public void submitImageDownloadTask(String URL, String id) {
		Callable<ImageDownloadResult> call = new ImageDownload(URL, id, downloadFolder, saveThumb,
				saveOriginal, followRedirects);
		pool.submit(call);
		numPendingTasks++;
	}