TODO: Use thread variable.
19778
private function get_pubcontrol()
    {
        if (is_null(self::$pub))
        {
            $scheme = null;
            if ($this->ssl)
                $scheme = 'https';
            else
                $scheme = 'http';
            self::$pub = new \PubControl\PubControlClient(
                    "{$scheme}://api.fanout.io/realm/" . "{$this->realm}");
            self::$pub->set_auth_jwt(array('iss' => $this->realm),
                    base64_decode($this->key));
        }
        return self::$pub;
    }
316100
def get_thread(self, thread_key):
		'''
		'''
		uri = '/'.join([self.api_uri,
						self.threads_suffix,
						thread_key
						])
		return self._req('get', uri)
1157407
@Override
	public Thread newThread(Runnable runnable) {
		Thread t = new Thread(group, runnable, namePrefix + threadNumber.getAndIncrement());
		t.setDaemon(true);

		t.setPriority(threadPriority);

		// optional handler for uncaught exceptions
		if (exceptionHandler != null) {
			t.setUncaughtExceptionHandler(exceptionHandler);
		}

		return t;
	}
940904
public void prime() {
        ThreadInfo[] ti = threading.dumpAllThreads(false, false);
        long[] tids = new long[ti.length];
        int n = 0;
        for(ThreadInfo t:ti) {
            long tid = t.getThreadId();
            String name = t.getThreadName();
            if (threadFilter == null || threadFilter.accept(name)) {
                tids[n++] = tid;
            }
        }
        tids = Arrays.copyOf(tids, n);
        threadSet = tids;
	}
1016925
public static ThreadDump create()
  {
    ThreadDump threadDump = _threadDumpRef.get();
    
    if (threadDump == null) {
      threadDump = new ThreadDumpPro();
      
      _threadDumpRef.compareAndSet(null, threadDump);
      threadDump = _threadDumpRef.get();
    }
    
    return threadDump;
  }
501000
static public Thread getThread(final long id) {
        final Thread[] threads = getAllThreads();
        for (Thread thread : threads)
            if (thread.getId() == id)
                return thread;
        return null;
    }
1072317
@Override
    public Thread newThread(final Runnable r) {
        final Thread t = new Thread(r, threadNamePrefix + threadIdx.getAndIncrement());
        t.setDaemon(daemon);
        return t;
    }
22432
def set_threadlocal(self, **values):
        """"""
        with self._lock:
            self._ensure_threadlocal()
            self._tpayload.context = values
1096948
static Thread newThread(String name, Runnable runnable) {
    checkNotNull(name);
    checkNotNull(runnable);
    Thread result = platformThreadFactory().newThread(runnable);
    try {
      result.setName(name);
    } catch (SecurityException e) {
      // OK if we can't set the name in this environment.
    }
    return result;
  }
1270367
public void run() {
		
		while( running ) {
			
			long interval_end = System.currentTimeMillis() + interval;
			
			while( interval_end > System.currentTimeMillis() ) {
				
				Thread.yield();
				
			}
			
			fireIntervalElapsed();
			
		}
		
		running = false;
		
	}
1290795
def Run(self):
    """"""
    for thread in itervalues(self._threads):
      thread.start()
    logging.info(START_STRING)

    while True:
      dead_threads = [
          tn for (tn, t) in iteritems(self._threads) if not t.isAlive()
      ]
      if dead_threads:
        raise FatalError(
            "These threads are dead: %r. Shutting down..." % dead_threads)
      time.sleep(10)
68068
@Given("^I save \'(.+?)\' in variable \'(.+?)\'$")
    public void saveInEnvironment(String value, String envVar) {
        ThreadProperty.set(envVar, value);
    }
331847
public static void startThread(Thread thread) {
        if (log.isDebugEnabled()) {
            log.debug("Starting background thread: " + thread);
        }

        ExecutorService executor = getTaskExecutor();

        if (executor != null) {
            executor.execute(thread);
        } else {
            thread.start();
        }
    }
134296
public static void tag(Object key, Object value)
    {
        Thread currentThread = Thread.currentThread();
        if (currentThread instanceof TaggableThread)
        {
            TaggableThread taggableThread = (TaggableThread) currentThread;
            taggableThread.tagMe(key, value);
        }
    }
1252766
synchronized private void startFrameThreads() {
    if(!process)
      return;
    int requests = unassignedEncodeRequests.size();
    int frames = inactiveFrameThreads.size();
    frames = (requests <= frames) ? requests:frames;
    for(int i = 0; i < frames; i++) {
      FrameThread ft = inactiveFrameThreads.remove(0);
      Thread thread = new Thread(ft);
      frameThreadMap.put(ft, thread);
      thread.start();
    }
  }
466107
@Override
  public void run(Context context) throws IOException, InterruptedException {
    outer = context;
    int numberOfThreads = getNumberOfThreads(context);
    mapClass = getMapperClass(context);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Configuring multithread runner to use " + numberOfThreads + 
                " threads");
    }
    
    runners =  new ArrayList<MapRunner>(numberOfThreads);
    for(int i=0; i < numberOfThreads; ++i) {
      MapRunner thread = new MapRunner(context);
      thread.start();
      runners.add(i, thread);
    }
    for(int i=0; i < numberOfThreads; ++i) {
      MapRunner thread = runners.get(i);
      thread.join();
      Throwable th = thread.throwable;
      if (th != null) {
        if (th instanceof IOException) {
          throw (IOException) th;
        } else if (th instanceof InterruptedException) {
          throw (InterruptedException) th;
        } else {
          throw new RuntimeException(th);
        }
      }
    }
  }
207411
private void done()
   {
      if (longThreadPool != null && isLong)
      {
         transport.updateLongRunningFree(address,
                                         longThreadPool.getNumberOfFreeThreads() + 1);
      }
      else
      {
         transport.updateShortRunningFree(address,
                                          shortThreadPool.getNumberOfFreeThreads() + 1);
      }
   }