Prepare threads to run tasks
482163
def start_parallel(self):
        
        for _ in range(self.num_threads):
            Worker(self.tasks_queue, self.results_queue, self.exceptions_queue)
45441
def cmd(send, *_):
    
    thread_names = []
    for x in sorted(threading.enumerate(), key=lambda k: k.name):
        res = re.match(r'Thread-(\d+$)', x.name)
        if res:
            tid = int(res.group(1))
            # Handle the main server thread (permanently listed as _worker)
            if x._target.__name__ == '_worker':
                thread_names.append((tid, "%s running server thread" % x.name))
            # Handle the multiprocessing pool worker threads (they don't have names beyond Thread-x)
            elif x._target.__module__ == 'multiprocessing.pool':
                thread_names.append((tid, "%s running multiprocessing pool worker thread" % x.name))
        # Handle everything else including MainThread and deferred threads
        else:
            res = re.match(r'Thread-(\d+)', x.name)
            tid = 0
            if res:
                tid = int(res.group(1))
            thread_names.append((tid, x.name))
    for x in sorted(thread_names, key=lambda k: k[0]):
        send(x[1])
122635
def task(name=None, t=INFO, *args, **kwargs):
    

    def c_run(name, f, t, args, kwargs):
        def run(*largs, **lkwargs):
            thread = __get_current_thread()
            old_name = __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY]
            __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY] = name

            r = log(name, f, t, largs, lkwargs, *args, **kwargs)

            __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY] = old_name
            return r

        return run

    if callable(name):
        f = name
        name = f.__name__

        return c_run(name, f, t, args, kwargs)

    if name == None:
        def wrapped(f):
            name = f.__name__
            return c_run(name, f, t, args, kwargs)

        return wrapped
    else:
        return lambda f: c_run(name, f, t, args, kwargs)
1370304
def start_task(self, method, *args, **kwargs):
        
        thread = threading.Thread(target=method, args=args, kwargs=kwargs)
        thread.is_daemon = False
        thread.start()
        self.threads.append(thread)
584751
void runTasks(Task[] tasks, int maxTaskIndex) {
        for (int i = 0; i <= maxTaskIndex; i++) {
            runTasksInChain(tasks[i]);
            tasks[i] = null;
        }
    }
1207274
def run_tasks(self):
        '''
        
        '''
        pool = Pool(len(self.tasks))
        for task in self.tasks:
            # Launch a green thread to schedule the task
            # A task will be managed by 2 green thread: execution thread and scheduling thread
            pool.spawn(self.run, task)
        return pool
920064
def Run(self):
    """"""
    count = 0
    for count, input_data in enumerate(self.GetInput()):
      if count % 2000 == 0:
        logging.debug("%d processed.", count)
      args = (input_data, self.out_queue, self.token)
      self.thread_pool.AddTask(
          target=self.IterFunction, args=args, name=self.THREAD_POOL_NAME)

    while count >= 0:
      try:
        # We only use the timeout to wait if we got to the end of the Queue but
        # didn't process everything yet.
        out = self.out_queue.get(timeout=self.QUEUE_TIMEOUT, block=True)
        if out:
          yield out
          count -= 1
      except queue.Empty:
        break

    # Join and stop to clean up the threadpool.
    self.thread_pool.Stop(join_timeout=THREADPOOL_JOIN_TIMEOUT)
1007631
def run(self):
        """"""
        event_handler = Handler()
        threads = []
        paths = [os.path.join(cwd, "content"), os.path.join(cwd, "templates")]

        for i in paths:
            targetPath = str(i)
            self.observer.schedule(event_handler, targetPath, recursive=True)
            threads.append(self.observer)

        self.observer.start()

        try:
            while True:
                time.sleep(5)
        except:
            self.observer.stop()
            print("\nObserver stopped.")

        self.observer.join()
684753
private void loadDataAsynchronously(
            @NonNull final Task<DataType, KeyType, ViewType, ParamType> task) {
        threadPool.submit(new Runnable() {

            @Override
            public void run() {
                if (!isCanceled()) {
                    while (!notifyOnLoad(task.key, task.params)) {
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            break;
                        }
                    }

                    task.result = loadData(task);
                    Message message = Message.obtain();
                    message.obj = task;
                    sendMessage(message);
                }
            }

        });
    }
44032
private void tasks() {
        Runnable r;
        while ( (r = sslEngine.getDelegatedTask()) != null) {
            r.run();
        }
        hs = sslEngine.getHandshakeStatus();
    }
344777
async def run_task(self, container, task, newthread = False):
        ""
        e = TaskEvent(self, task=task, newthread = newthread)
        await container.wait_for_send(e)
        ev = await TaskDoneEvent.createMatcher(e)
        if hasattr(ev, 'exception'):
            raise ev.exception
        else:
            return ev.result
28168
def run_in_thread_pool(self, pool_size=None, func=None, *args):
        """"""
        executor = Pool(pool_size)
        return self.loop.run_in_executor(executor, func, *args)
1187197
private ArrayList<ThreadContext> startTask(ThreadContextDescriptor raThreadContextDescriptor) {
        return raThreadContextDescriptor == null ? null : raThreadContextDescriptor.taskStarting();
    }
553661
def submit_task(rel_path, cache_string, buffer):
    """"""
    global upload_queue
    global upload_thread
    upload_queue.put((rel_path, cache_string, buffer))

    if upload_thread is None or not upload_thread.is_alive():
        upload_thread = UploaderThread()
        upload_thread.start()
261863
def run(self):
        """"""
        (task_id, tasks) = self.server.get_task()
        self.task_store.from_dict(tasks)
        for (index, task) in self.task_store:
            result = self.compute(index, task)
            self.results.append(result)
        self.server.task_done((task_id, self.results))
1335965
@Override
	public void run() {
		Collection<Writer> writers = new ArrayList<Writer>(1);

		while (true) {
			for (Task task : receiveTasks()) {
				if (task == Task.POISON) {
					close();
					return;
				} else {
					write(writers, task);
				}
			}

			flush(writers);
			writers.clear();

			try {
				sleep(MILLISECONDS_TO_SLEEP);
			} catch (InterruptedException ex) {
				// Ignore and continue
			}
		}
	}
703536
public void executeInIoThread(Runnable task, boolean alwaysAsync) {
        if (!alwaysAsync && isIoThread()) {
            task.run();
        } else {
            registerTask(task);
        }
    }