List of usage examples for java.lang Thread currentThread
@HotSpotIntrinsicCandidate public static native Thread currentThread();
From source file:com.refreshsf.contrib.client.tests.ResourceUtil.java
public static InputStream getResourceInputStream(String fileName) { return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); }
From source file:Main.java
/** Return the method name of the callee. */ public static String getMethodName() { final StackTraceElement[] s = Thread.currentThread().getStackTrace(); return s[s.length > 2 ? 2 : s.length - 1].getMethodName(); }
From source file:Main.java
public static ThreadGroup rootThreadGroup() { ThreadGroup tg = Thread.currentThread().getThreadGroup(); ThreadGroup ptg = tg.getParent(); while (ptg != null) { tg = ptg;// w ww .ja va 2 s . co m ptg = tg.getParent(); } return tg; }
From source file:Main.java
public static ArrayList<Thread> getThreads() { // Find the root thread group ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); while (root.getParent() != null) { root = root.getParent();//ww w . j av a 2 s . c om } ArrayList<Thread> threads = new ArrayList<Thread>(); visit(root, 0, threads); return threads; }
From source file:Main.java
/** * Returns <tt>true</tt> if current <tt>Thread</tt> is UI thread. * @return <tt>true</tt> if current <tt>Thread</tt> is UI thread. *//* w w w . j a v a 2 s . co m*/ public static boolean isUIThread() { return Looper.getMainLooper().getThread() == Thread.currentThread(); }
From source file:jp.co.cyberagent.parquet.msgpack.JSONLinesIterator.java
public static JSONLinesIterator fromResource(String name) { File file = new File(Thread.currentThread().getContextClassLoader().getResource(name).getPath()); return new JSONLinesIterator(file); }
From source file:com.civis.utils.opennlp.models.BaseModelTest.java
protected static String getTextExample(String fileName) { String content = ""; try (InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(fileName)) { content = IOUtils.toString(inputStream, "UTF-8"); inputStream.close();//from w w w . jav a 2 s. c o m } catch (IOException e) { Assert.fail(); } return content; }
From source file:Main.java
public static boolean handleInterrruptedException(Throwable e) { // A helper to deal with the interrupt exception // If an interrupt detected, we will setup the bit again. if (e instanceof InterruptedIOException || e instanceof InterruptedException) { Thread.currentThread().interrupt(); return true; }/*from w w w. jav a2 s .co m*/ return false; }
From source file:Main.java
/** * Get the thread id/*from w w w. ja v a 2s . c om*/ * * @return the thread id */ public static long getThreadId() { final Long threadId = THREAD_LOCAL.get(); if (threadId != null) { return threadId; } return Thread.currentThread().getId(); }
From source file:com.redhat.red.build.koji.testutil.TestResourceUtils.java
public static byte[] readTestResourceBytes(String resource) throws IOException { try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) { return IOUtils.toByteArray(in); }//from ww w .jav a2s .com }