Skip to content

Instantly share code, notes, and snippets.

@ssmiech
Created January 17, 2018 15:21
Show Gist options
  • Save ssmiech/9630fef58f875467dadfddd17ed0e118 to your computer and use it in GitHub Desktop.
Save ssmiech/9630fef58f875467dadfddd17ed0e118 to your computer and use it in GitHub Desktop.
If I ever need to figure out which threads are running when testing with Espresso
private void dumpThreads() {
int activeCount = Thread.activeCount();
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);
for (Thread thread : threads) {
System.err.println(thread.getName() + ": " + thread.getState());
for (StackTraceElement stackTraceElement : thread.getStackTrace()) {
System.err.println("\t" + stackTraceElement);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment