Decorator to create automatically a :class:`Runnable` object with the
    function. The function will be delayed and call into the Activity thread.
557703
def run_on_ui_thread(f):
    '''
    '''
    def f2(*args, **kwargs):
        Runnable(f)(*args, **kwargs)
    return f2
886117
def runner(self, fun, **kwargs):
        '''
        
        '''
        return self.pool.fire_async(self.client_cache['runner'].low, args=(fun, kwargs))
1366942
def run_on(*, event: str):
        """"""

        def decorator(callback):
            @functools.wraps(callback)
            def decorator_wrapper():
                RTMClient.on(event=event, callback=callback)

            return decorator_wrapper()

        return decorator
578425
def Synchronized(f):
  """"""

  @functools.wraps(f)
  def NewFunction(self, *args, **kw):
    with self.lock:
      return f(self, *args, **kw)

  return NewFunction
416648
public Runnable asRunnable() {
        return new Runnable() {
            @Override
            public void run() {
                try {
                    callable.call();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        };
    }
1157436
def create_thread(daemon, callback, *callbackParams):
    
    task = Thread(target=callback, args=callbackParams)
    task.setDaemon(daemon)
    return task
35622
protected final void runOnUiThread(@NonNull Runnable runnable) {
        checkNotNull(runnable, "runnable");
        if (Looper.myLooper() == Looper.getMainLooper()) {
            runnable.run();
        } else {
            mPoster.post(runnable);
        }
    }
375039
def wrap_threading_run(run_func):
    

    def call(self):
        execution_context.set_opencensus_full_context(
            *self._opencensus_context
        )
        return run_func(self)

    return call
1306232
def _enable_thread_pool(func):
    

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        self = args[0]
        if self.enable_thread_pool and hasattr(self, 'thread_pool'):
            future = self.thread_pool.submit(func, *args, **kwargs)
            is_async = kwargs.get('is_async')
            if is_async is None or not is_async:
                timeout = kwargs.get('timeout')
                if timeout is None:
                    timeout = 2
                try:
                    result = future.result(timeout=timeout)
                except TimeoutError as e:
                    self.logger.exception(e)
                    result = None
                return result
            return future
        else:
            return func(*args, **kwargs)

    return wrapper
1310598
def run(self, *args, **kwargs) -> Callable:
        
        return self.fn(*args, **kwargs) if args or kwargs else self.fn
1197784
def _timed_run(self, func, distribution, args=(), kwargs={},  default=None):
        
        class InterruptableThread(threading.Thread):
            def __init__(self):
                threading.Thread.__init__(self)
                self.result = default
                self.exc_info = (None, None, None)

            def run(self):
                try:
                    self.result = func(args, **kwargs)
                except Exception as err:
                    self.exc_info = sys.exc_info()

            def suicide(self):
                raise RuntimeError('Stop has been called')

        it = InterruptableThread()
        it.start()
        started_at = datetime.now()
        it.join(self.timeout)
        ended_at = datetime.now()
        diff = ended_at - started_at

        if it.exc_info[0] is not None:  # if there were any exceptions
            a,b,c = it.exc_info
            raise Exception(a,b,c)  # communicate that to caller

        if it.isAlive():
            it.suicide()
            raise RuntimeError
        else:
            return it.result
33852
def wrap(self, func, delay=0):
        '''
        
        '''
        def wrapped():
            self.start()
            if delay:
                self.sleep(delay)
            x = None
            try:
                x = func()
            except OSError as oserror:
                log.debug('OSError exception:%s', oserror)
                self.oserror = oserror
                raise EasyProcessError(self, 'wrap error!')
            finally:
                self.stop()
            return x
        return wrapped
76937
public static void invokeOnEventDispatchThread(Runnable runnable)
    {
        if (SwingUtilities.isEventDispatchThread())
        {
            runnable.run();
        }
        else
        {
            SwingUtilities.invokeLater(runnable);
        }
    }
1012020
public function setRunnable( $_runnable ) {
		if( self::runnableOk( $_runnable ) ) {
			$this->runnable = $_runnable;
		}
		else {
			throw new Exception( $this->getError( Thread::FUNCTION_NOT_CALLABLE ), Thread::FUNCTION_NOT_CALLABLE );
		}
	}
846889
private Runnable createProcessRunner(final BlockingQueue<FlowletProcessEntry<?>> processQueue,
                                       final List<FlowletProcessEntry<?>> processList,
                                       final ClassLoader classLoader) {
    return new Runnable() {
      @Override
      public void run() {
        Thread.currentThread().setContextClassLoader(classLoader);
        for (FlowletProcessEntry<?> entry : processList) {
          if (!handleProcessEntry(entry, processQueue)) {
            processQueue.offer(entry);
          }
        }
      }
    };
  }
987016
def threadpooled(
    func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]],
    *,
    loop_getter: None = None,
    loop_getter_need_context: bool = False,
) -> typing.Callable[..., "concurrent.futures.Future[typing.Any]"]:
    """"""
603779
def run(self):
        
        target = getattr(self, '_Thread__target', getattr(self, '_target', None))
        args = getattr(self, '_Thread__args', getattr(self, '_args', None))
        kwargs = getattr(self, '_Thread__kwargs', getattr(self, '_kwargs', None))
        if target is not None:
            self._return = target(*args, **kwargs)

        return None