Gets an immutable copy of this current thread's context stack.

@return an immutable copy of the ThreadContext stack.
169640
public static ContextStack getImmutableStack() {
        final ContextStack result = contextStack.getImmutableStackOrNull();
        return result == null ? EMPTY_STACK : result;
    }
611873
private Context getContext() {
        Context context = mContext.get();
        if (context == null) {
            throw new IllegalStateException("Context used by the instance has been destroyed.");
        }
        return context;
    }
591524
public static ControlContainerContext getContext() 
    {
        Stack<ControlContainerContext> contextStack = _threadContexts.get();
        if (contextStack == null || contextStack.size() == 0)
            return null;

        return contextStack.peek();
    }
1186311
public T copy() {
        T copy = Instantiator.of(type).instantiate();
        return copyInto(copy);
    }
515736
@Override
  public int getCurrentStackSize() {
    int stackSize = -1;
    if (this.tracingContextMap.containsKey(Thread.currentThread()))
      stackSize = this.tracingContextMap.get(Thread.currentThread()).getMethodStack().size();
    
    return stackSize;
  }
918163
public ContextStack<T> copyPush(final T value) {
        final ContextStack<T> stack1 = copy();
        stack1.push(value);
        return stack1;
    }
750722
public T get() {
        while (true) {
            Thread t = threadVar.get();
            if (t == null) {
                return getValue();
            }
            try {
                t.join();
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt(); // propagate
                return null;
            }
        }
    }
836687
public T copy() {
        T ret = createLike();
        ret.getMatrix().set(this.getMatrix());
        return ret;
    }
423548
public static String threadDump()
    {
        final StringBuilder sb = new StringBuilder();
        final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();

        for (final ThreadInfo info : threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), Integer.MAX_VALUE))
        {
            sb.append('"').append(info.getThreadName()).append("\": ").append(info.getThreadState());

            for (final StackTraceElement stackTraceElement : info.getStackTrace())
            {
                sb.append("\n    at ").append(stackTraceElement.toString());
            }

            sb.append("\n\n");
        }

        return sb.toString();
    }
282343
public static RequestContext get() {
        if (CURRENT_CONTEXT.get() == null) {
            synchronized (RequestContext.class) {
                if (CURRENT_CONTEXT.get() == null) {
                    createContext();
                }
            }
        }

        // ensure that RequestContextV1 is also initialized for this request
        RequestContextV1.get();

        return CURRENT_CONTEXT.get();
    }
855633
public ContextItems getMarshaledContext() {
        ContextItems marshaledContext = new ContextItems();

        for (IManagedContext<?> managedContext : managedContexts) {
            marshaledContext.addItems(managedContext.getContextItems(false));
        }

        return marshaledContext;
    }
364195
public synchronized ManageableCacheValue getNextCacheValue() {
        //changes to the map are reflected on the keySet. And its iterator is weakly consistent. so will never
        //throw concurrent modification exception.
        if (iterator.hasNext()) {
            return hashMap.get(iterator.next().getKey());
        } else {
            resetIterator();
            return null;
        }
    }
1020793
@SuppressWarnings("unchecked")
    private ThreadLocalProxyCopyOnWriteArraySet<ThreadLocalProxy<?>> getProxySet() {
        Object property = null;
        property = bus.getProperty(PROXY_SET);
        if (property == null) {
            ThreadLocalProxyCopyOnWriteArraySet<ThreadLocalProxy<?>> proxyMap = new ThreadLocalProxyCopyOnWriteArraySet<ThreadLocalProxy<?>>();

            bus.setProperty(PROXY_SET, proxyMap);
            property = proxyMap;
        }
        return (ThreadLocalProxyCopyOnWriteArraySet<ThreadLocalProxy<?>>) property;
    }
1134931
public @Nonnull SetType getBlockingThreads() {
        final ThreadType blocking = getBlockingThread();
        if (blocking == null) return runtime.getEmptyThreadSet();

        return runtime.getThreadSet(Collections.singleton(blocking));
    }
1011794
public E take() throws InterruptedException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            for (;;) {
                E first = q.peek();
                if (first == null)
                    available.await();
                else {
                    long delay = first.getDelay(NANOSECONDS);
                    if (delay <= 0L)
                        return q.poll();
                    first = null; // don't retain ref while waiting
                    if (leader != null)
                        available.await();
                    else {
                        Thread thisThread = Thread.currentThread();
                        leader = thisThread;
                        try {
                            available.awaitNanos(delay);
                        } finally {
                            if (leader == thisThread)
                                leader = null;
                        }
                    }
                }
            }
        } finally {
            if (leader == null && q.peek() != null)
                available.signal();
            lock.unlock();
        }
    }
1367007
public ThreadUsage getThreadUsage() {
        ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();

        ThreadUsage threadUsage = new ThreadUsage();
        long[] threadIds = threadMxBean.getAllThreadIds();
        threadUsage.liveThreadCount = threadIds.length;

        for (long tId : threadIds) {
            ThreadInfo threadInfo = threadMxBean.getThreadInfo(tId);
            threadUsage.threadData.put(Long.toString(tId), new ThreadData(
                    threadInfo.getThreadName(), threadInfo.getThreadState()
                            .name(), threadMxBean.getThreadCpuTime(tId)));

        }
        return threadUsage;
    }
102480
public CompilerThread grabCompilerThread() throws InterruptedException {
        available.acquire();
        if (compilers.empty()) {
            return new CompilerThread(this);
        }
        return compilers.pop();
    }