Returns thread-local formatter. Inner Appendable is StringBuider which's
length is set to 0.
@return
545431
public static Formatter getFormatter()
    {
        Formatter formatter = out.get();
        if (formatter == null)
        {
            formatter = new Formatter(new StringBuilder());
            out.set(formatter);
        }
        else
        {
            StringBuilder sb = (StringBuilder) formatter.out();
            sb.setLength(0);
        }
        return formatter;
    }
818761
public FormattedStringBuilder append(Throwable t) { 
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        PrintStream p = new PrintStream(os);
        t.printStackTrace(p);
        p.close();
        return append(os.toString());
    }
848578
public Set<String> getDeadlockedThreads() {
    final long[] threadIds = threads.findDeadlockedThreads();
    if (threadIds != null) {
      final Set<String> threads = new HashSet<String>();
      for (ThreadInfo info : this.threads.getThreadInfo(threadIds, MAX_STACK_TRACE_DEPTH)) {
        final StringBuilder stackTrace = new StringBuilder();
        for (StackTraceElement element : info.getStackTrace()) {
          stackTrace.append("\t at ").append(element.toString()).append('\n');
        }

        threads.add(
          String.format(
            "%s locked on %s (owned by %s):\n%s",
            info.getThreadName(), info.getLockName(),
            info.getLockOwnerName(),
            stackTrace.toString()));
      }
      return Collections.unmodifiableSet(threads);
    }
    return Collections.emptySet();
  }
182076
public static Format getFormat(String className) {
		assert className != null;
		if (className.isEmpty()) {
			return null;
		}

		ThreadLocal<Format> tlsFormatter = classFormatters.get(className);
		if (tlsFormatter == null) {
			try {
				// append formatter class name to cache only if exists and is of right type
				Classes.forName(className);
				tlsFormatter = new ThreadLocal<Format>();
				classFormatters.put(className, tlsFormatter);
			} catch (NoSuchBeingException e) {
				log.error("Formatter class |%s| not found.", className);
				return null;
			} catch (ClassCastException e) {
				log.error("Invalid formatter class |%s|. It should inherit from |%s|.", className, Format.class);
				return null;
			}
		}

		Format formatter = tlsFormatter.get();
		if (formatter == null) {
			formatter = createFormatter(className);
			if (formatter == null) {
				// formatter can be invalid only if miss proper constructor and this is for sure a flaw in logic
				throw new BugError("Invalid formatter class |%s|. Proper constructor not found.", className);
			}
			tlsFormatter.set(formatter);
		}
		return formatter;
	}
113194
public Thread getExecutingThread() {
		synchronized (this) {

			if (this.executingThread == null) {
				if (this.taskName == null) {
					this.executingThread = new Thread(this);
				}
				else {
					this.executingThread = new Thread(this, getTaskNameWithIndex());
				}
			}

			return this.executingThread;
		}
	}
843406
private String getThreadType(DispatchQueueSelector queueSelector) {
        String threadType;
        if (queueSelector instanceof DiscordApi) {
            threadType = "a global listener thread";
        } else if (queueSelector == null) {
            threadType = "a connection listener thread";
        } else {
            threadType = String.format("a listener thread for %s", queueSelector);
        }
        return threadType;
    }
345263
@Nullable
    public static ThreadFactory unwrap(@Nullable ThreadFactory threadFactory) {
        if (!isDisableInheritableThreadFactory(threadFactory)) return threadFactory;

        return ((DisableInheritableThreadFactory) threadFactory).unwrap();
    }
227446
private Object getFormatter() {
        Object f = iFormatter;

        if (f == null) {
            if (iElementPairs.size() == 2) {
                Object printer = iElementPairs.get(0);
                Object parser = iElementPairs.get(1);

                if (printer != null) {
                    if (printer == parser || parser == null) {
                        f = printer;
                    }
                } else {
                    f = parser;
                }
            }

            if (f == null) {
                f = new Composite(iElementPairs);
            }

            iFormatter = f;
        }

        return f;
    }
114943
public static String dumpThreads() {
        final StringWriter sout = new StringWriter(); // Capture listing in a
        // string
        final PrintWriter out = new PrintWriter(sout);
        Util.listAllThreads(out);
        out.flush();
        return sout.toString();
    }
481435
private static <T> ThreadContext<T> getCurrentThreadContext(ThreadContext<T> threadContext)
    {
        return ((ThreadContextImpl<T>) threadContext).get();
    }
1309295
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
            value = {"VA_FORMAT_STRING_USES_NEWLINE"},
            justification = "We don't want platform specific"
    )
    public static void threadDump(OutputStream out) throws UnsupportedEncodingException {
        final PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "utf-8"), true);

        ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
        ThreadInfo[] threads;
        try {
            threads = mbean.dumpAllThreads(mbean.isObjectMonitorUsageSupported(), mbean.isSynchronizerUsageSupported());
        } catch (UnsupportedOperationException x) {
            SupportLogFormatter.printStackTrace(x, writer);
            threads = new ThreadInfo[0];
        }

        Arrays.sort(threads, new Comparator<ThreadInfo>() {
            @Override
            public int compare(ThreadInfo t1, ThreadInfo t2) {
                return t1.getThreadName().compareTo(t2.getThreadName());
            }
        });
        for (ThreadInfo t : threads) {
            printThreadInfo(writer, t, mbean);
        }

        // Print any information about deadlocks.
        long[] deadLocks;
        try {
            deadLocks = mbean.findDeadlockedThreads();
        } catch (UnsupportedOperationException x) {
            SupportLogFormatter.printStackTrace(x, writer);
            deadLocks = null;
        }
        if (deadLocks != null && deadLocks.length != 0) {
            writer.println(" Deadlock Found ");
            ThreadInfo[] deadLockThreads = mbean.getThreadInfo(deadLocks);
            for (ThreadInfo threadInfo : deadLockThreads) {
                StackTraceElement[] elements = threadInfo.getStackTrace();
                for (StackTraceElement element : elements) {
                    writer.println(element.toString());
                }
            }
        }

        writer.println();
        writer.flush();
    }
330932
public static ClassLoader getThreadContextClassLoader()
    {
        Thread thread=Thread.currentThread();
        ClassLoader classLoader=thread.getContextClassLoader();
        
        return classLoader;
    }
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;
	}
969231
public static final CThreadContext getInstance() {
		SoftReference ref = (SoftReference)CThreadContext.contextLocal
				.get(Thread.currentThread());
		CThreadContext context = null;
		if ((ref == null) || (ref.get() == null)) {
			context = new CThreadContext();
			ref = new SoftReference(context);
			CThreadContext.contextLocal.put(Thread.currentThread(), ref);
		} else {
			context = (CThreadContext)ref.get();
		}
		return context;
	}
478919
@Override
    public String getFormattedMessage() {
        if (formattedMessage == null) {
            final StringBuilder buffer = getThreadLocalStringBuilder();
            formatTo(buffer);
            formattedMessage = buffer.toString();
            StringBuilders.trimToMaxSize(buffer, Constants.MAX_REUSABLE_MESSAGE_SIZE);
        }
        return formattedMessage;
    }
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;
    }
51279
@SuppressWarnings("unchecked")
    public final V get() {
        InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get();
        Object v = threadLocalMap.indexedVariable(index);
        if (v != InternalThreadLocalMap.UNSET) {
            return (V) v;
        }

        return initialize(threadLocalMap);
    }