Start a new preview thread if one isn't already running. Carefully manipulate variables due to threading
508158
void showPreview( String path ) {
        synchronized (lockPreview) {
            if( path == null ) {
                pendingPreview = null;
            } else if( previewThread == null ) {
                pendingPreview = path;
                previewThread = new PreviewThread();
                previewThread.start();
            } else {
                pendingPreview = path;
            }
        }
    }
1209826
def _StartStatusUpdateThread(self):
    """"""
    self._status_update_active = True
    self._status_update_thread = threading.Thread(
        name='Status update', target=self._StatusUpdateThreadMain)
    self._status_update_thread.start()
330132
def __start_thread(self):
        
        with self.__lock:
            if self.__nb_threads >= self._max_threads:
                # Can't create more threads
                return False

            if self._done_event.is_set():
                # We're stopped: do nothing
                return False

            # Prepare thread and start it
            name = "{0}-{1}".format(self._logger.name, self._thread_id)
            self._thread_id += 1

            thread = threading.Thread(target=self.__run, name=name)
            thread.daemon = True
            try:
                self.__nb_threads += 1
                thread.start()
                self._threads.append(thread)
                return True
            except (RuntimeError, OSError):
                self.__nb_threads -= 1
                return False
53655
def run(self):
        """"""
        notice('Starting output thread', self.color)
        o = Thread(target=self.__output_thread, name='output')
        o.start()
        self.threads.append(o)
        try:
            notice('Starting input thread', self.color)
            self.__input_thread()
        except KeyboardInterrupt:
            self.__shutdown()
333214
@Override
    public void postToMainThread(Runnable runnable) {
        if (mMainHandler == null) {
            synchronized (mLock) {
                if (mMainHandler == null) {
                    mMainHandler = new Handler(Looper.getMainLooper());
                }
            }
        }
        //noinspection ConstantConditions
        mMainHandler.post(runnable);
    }
724011
void startThread() {

        m_reportPanel.setVisible(true);
        m_startPanel.setVisible(false);
        m_report.setVisible(false);
        CmsStaticExportThread thread = new CmsStaticExportThread(A_CmsUI.getCmsObject());
        CmsReportWidget report = new CmsReportWidget(thread);
        report.setHeight("500px");
        report.setWidth("100%");
        m_layout.addComponent(report);
        thread.start();
    }
421421
def prepare_threads(new_function):
    """"""
    with _waitforthreads_lock:
        if hasattr(threading, 'get_ident'):
            old_function = threading.get_ident
            threading.get_ident = new_function
        else:
            old_function = threading._get_ident
            threading._get_ident = new_function

        return old_function
932070
def watch(watch_value, &block)
      new_thread = Thread.new do
        prev_value = (self.read == GPIO_HIGH ? GPIO_LOW : GPIO_HIGH)

        loop do
          current_value = self.read
          flip = (prev_value != current_value)

          if current_value == watch_value && flip
            self.instance_exec &block
          end

          prev_value = current_value

          sleep WATCH_POLLING_SEC
        end
      end

      new_thread.abort_on_exception = true
      new_thread
    end
1272122
public void start() {
		Thread thread = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					onPreExecute();
					Value value = execute();
					onPostExecute(value);
				} catch (Throwable throwable) {
					onThrowable(throwable);
				}
			}
		});
		thread.start();
	}
600833
def start(io_loop=None, check_time=2):

    
    io_loop = io_loop or asyncio.get_event_loop()
    if io_loop in _io_loops:
        return
    _io_loops[io_loop] = True
    if len(_io_loops) > 1:
        logger.warning("aiohttp_autoreload started more than once in the same process")
    # if _has_execv:
    #     add_reload_hook(functools.partial(io_loop.close, all_fds=True))
    modify_times = {}
    callback = functools.partial(_reload_on_update, modify_times)
    logger.debug("Starting periodic checks for code changes")
    call_periodic(check_time, callback, loop=io_loop)
371792
def start_monitoring(seconds_frozen=SECONDS_FROZEN,
                     test_interval=TEST_INTERVAL):
    
    
    thread = StoppableThread(target=monitor, args=(seconds_frozen,
                                                   test_interval))
    thread.daemon = True
    thread.start()
    return thread
449479
function startFPSMonitor() {
        checkInit();
        var data = new Data();
        var w = new MonitorWidget("FPS", "", 2 /* HideMax */ | 1 /* HideMin */ | 4 /* HideMean */ | 32 /* RoundValues */);
        container.appendChild(w.element);
        var samples = [];
        var last = 0;
        function update(now) {
            var elapsed = (now - (last === 0 ? now : last)) / 1000;
            var fps = 1 / elapsed;
            if (fps !== Infinity) {
                if (samples.length === 64) {
                    samples.shift();
                }
                samples.push(fps);
                var sum = 0;
                for (var i = 0; i < samples.length; i++) {
                    sum += samples[i];
                }
                var mean = sum / samples.length;
                data.addSample(mean);
                w.addResult(data.calc());
            }
            last = now;
            requestAnimationFrame(update);
        }
        requestAnimationFrame(update);
    }
1098940
public void start() {

		if (!started.compareAndSet(false, true)) {
			return;
		}

		LOG.debug("Starting panel rendering and trying to open attached webcam");

		starting = true;

		if (updater == null) {
			updater = new ImageUpdater();
		}

		updater.start();

		try {
			errored = !webcam.open();
		} catch (WebcamException e) {

			errored = true;

			Display.getDefault().syncExec(new Runnable() {

				@Override
				public void run() {
					redraw();
				}
			});

			throw e;
		} finally {
			starting = false;
		}
	}
786959
def preview(self, argv):
        """"""
        opts = cmdline(argv, FLAGS_RESULTS)
        self.foreach(opts.args, lambda job: 
            output(job.preview(**opts.kwargs)))
163549
def _start_handler_thread(self):
        """"""
        # Create handler thread
        t = Thread(target=self._start_loop)
        t.daemon = True

        # Start handler thread
        t.start()
        self.thread_started = True
75852
def _start_auto_refresh_thread(self):
        
        def run():
            while True:
                time.sleep(self.status_interval)
                self.invalidate()

        t = threading.Thread(target=run)
        t.daemon = True
        t.start()
1037547
def thread_started(self):
		
		self.__running_record_registry.start()
		self.__running_record_registry.start_event().wait()
		WPollingThreadTask.thread_started(self)