A null-safe method for getting the Thread's current state.

@param thread the Thread from which the state is returned.
@return the State of the specified Thread or null if the Thread is null.
@see java.lang.Thread#getState()
@see java.lang.Thread.State
968847
@NullSafe
  public static Thread.State getState(Thread thread) {
    return (thread != null ? thread.getState() : null);
  }
1147854
@Override
    public SensorState getState() {
        if(pin.isState(openState))
            return SensorState.OPEN;
        else
            return SensorState.CLOSED;
    }
1258100
public @CheckForNull JvmThread forThread(@CheckForNull Thread needle) {
        if (needle == null) return null;

        for (JvmThread candidate: this) {
            final JvmThread jvmThread = candidate;
            if (needle.equals(jvmThread.getThread())) return jvmThread;
        }
        return null;
    }
995780
private int defaultThreadID() {
        long tid = Thread.currentThread().getId();
        if (tid < MIN_SEQUENTIAL_THREAD_ID) {
            return (int) tid;
        } else {
            Integer id = threadIds.get();
            if (id == null) {
                id = nextThreadId.getAndIncrement();
                threadIds.set(id);
            }
            return id;
        }
    }
314034
protected int getState() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getState");
        int tempState;
        synchronized (stateLock) {
            tempState = state;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getState", state);
        return tempState;
    }
430157
static long getThreadStateCount(ThreadMXBean threadBean, Thread.State state) {
        return Arrays.stream(threadBean.getThreadInfo(threadBean.getAllThreadIds()))
                .filter(threadInfo -> threadInfo != null && threadInfo.getThreadState() == state)
                .count();
    }
1184955
public static Map<String, Object> get() {
		Map<String, Object> map = JKThreadLocal.thread.get();
		if (map == null) {
			map = new LinkedHashMap<String, Object>();
			JKThreadLocal.set(map);
		}
		return map;
	}
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();
        }
    }
897895
static @Nullable <V> V getWhenSuccessful(@Nullable CompletableFuture<V> future) {
    try {
      return (future == null) ? null : future.get();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      return null;
    } catch (ExecutionException e) {
      return null;
    }
  }
465163
@Override
    public RelayState getState() {
        if(pin.isState(openState))
            return RelayState.OPEN;
        else
            return RelayState.CLOSED;
    }
1269346
@SuppressWarnings("unchecked")
    public T get() {
        if (HystrixRequestContext.getContextForCurrentThread() == null) {
            throw new IllegalStateException(HystrixRequestContext.class.getSimpleName() + ".initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.");
        }
        ConcurrentHashMap<HystrixRequestVariableDefault<?>, LazyInitializer<?>> variableMap = HystrixRequestContext.getContextForCurrentThread().state;

        // short-circuit the synchronized path below if we already have the value in the ConcurrentHashMap
        LazyInitializer<?> v = variableMap.get(this);
        if (v != null) {
            return (T) v.get();
        }

        /*
         * Optimistically create a LazyInitializer to put into the ConcurrentHashMap.
         * 
         * The LazyInitializer will not invoke initialValue() unless the get() method is invoked
         * so we can optimistically instantiate LazyInitializer and then discard for garbage collection
         * if the putIfAbsent fails.
         * 
         * Whichever instance of LazyInitializer succeeds will then have get() invoked which will call
         * the initialValue() method once-and-only-once.
         */
        LazyInitializer<T> l = new LazyInitializer<T>(this);
        LazyInitializer<?> existing = variableMap.putIfAbsent(this, l);
        if (existing == null) {
            /*
             * We won the thread-race so can use 'l' that we just created.
             */
            return l.get();
        } else {
            /*
             * We lost the thread-race so let 'l' be garbage collected and instead return 'existing'
             */
            return (T) existing.get();
        }
    }
949123
public static void waitForDie(Thread thread) {
		boolean dead = false;
		do {
			try {
				thread.join();
				dead = true;
			} catch (InterruptedException e) {
				// ignore
			}
		} while (!dead);
	}
181884
def _getThread(self, given_thread_id=None, given_thread_type=None):
        
        if given_thread_id is None:
            if self._default_thread_id is not None:
                return self._default_thread_id, self._default_thread_type
            else:
                raise ValueError("Thread ID is not set")
        else:
            return given_thread_id, given_thread_type
1304713
public static final String getThreadId() {
        String id = threadids.get();
        if (null == id) {
            // Pad the tid out to 8 characters
            id = getThreadId(Thread.currentThread());
            threadids.set(id);
        }
        return id;
    }
316100
def get_thread(self, thread_key):
		'''
		'''
		uri = '/'.join([self.api_uri,
						self.threads_suffix,
						thread_key
						])
		return self._req('get', uri)
501000
static public Thread getThread(final long id) {
        final Thread[] threads = getAllThreads();
        for (Thread thread : threads)
            if (thread.getId() == id)
                return thread;
        return null;
    }
594055
protected boolean isMain(Thread thread) {
		return thread.getName().equals("main") && thread.getContextClassLoader()
				.getClass().getName().contains("AppClassLoader");
	}