java.lang.Thread.dumpStack()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(310)

本文整理了Java中java.lang.Thread.dumpStack()方法的一些代码示例,展示了Thread.dumpStack()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.dumpStack()方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:dumpStack

Thread.dumpStack介绍

[英]Prints a stack trace of the current thread to the standard error stream. This method is used only for debugging.
[中]将当前线程的堆栈跟踪打印到标准错误流。此方法仅用于调试。

代码示例

代码示例来源:origin: apache/geode

public PortfolioPdx() {
 this.numInstance++;
 if (DEBUG)
  Thread.dumpStack();
 // GemFireCacheImpl.getInstance().getLogger().fine(new Exception("DEBUG"));
}

代码示例来源:origin: ming1016/study

public static void die(String msg, Exception e) {
  System.err.println(msg);
  if (e != null) {
    System.err.println("Exception: " + e + "\n");
  }
  Thread.dumpStack();
  System.exit(2);
}

代码示例来源:origin: ming1016/study

public static void die(String msg, Exception e) {
  System.err.println(msg);
  if (e != null) {
    System.err.println("Exception: " + e + "\n");
  }
  Thread.dumpStack();
  System.exit(2);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void handleMessage(int source, int type, int id, int severity, String message) {
  String sourceStr = constMap.get(source);
  String typeStr = constMap.get(type);
  String severityStr = constMap.get(severity);
  
  System.err.println(String.format(MESSAGE_FORMAT, id, sourceStr, typeStr, severityStr, message));
  Thread.dumpStack();
}

代码示例来源:origin: kilim/kilim

public static void errNotWoven() {
  System.err.println("############################################################");
  System.err.println("Task has either not been woven or the classpath is incorrect");
  System.err.println("############################################################");
  Thread.dumpStack();
  System.exit(0);
}

代码示例来源:origin: kilim/kilim

public static void errNotWoven(Task t) {
  System.err.println("############################################################");
  System.err.println("Task " + t.getClass()
      + " has either not been woven or the classpath is incorrect");
  System.err.println("############################################################");
  Thread.dumpStack();
  System.exit(0);
}

代码示例来源:origin: thinkaurelius/titan

@Override
@After
public void tearDown() throws Exception {
  executor.shutdown();
  if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
    log.error("Abnormal executor shutdown");
    Thread.dumpStack();
  } else {
    log.debug("Test executor completed normal shutdown");
  }
  super.tearDown();
}

代码示例来源:origin: AdoptOpenJDK/jitwatch

public static long parseStamp(String stamp)
{
  long result = 0;
  if (stamp != null)
  {
    double number = parseLocaleSafeDouble(stamp);
    result = (long) (number * 1000);
  }
  else
  {
    logger.warn("Could not parse null stamp");
    Thread.dumpStack();
  }
  return result;
}

代码示例来源:origin: AdoptOpenJDK/jitwatch

public static long parseStamp(String stamp)
{
  long result = 0;
  if (stamp != null)
  {
    double number = parseLocaleSafeDouble(stamp);
    result = (long) (number * 1000);
  }
  else
  {
    logger.warn("Could not parse null stamp");
    Thread.dumpStack();
  }
  return result;
}

代码示例来源:origin: JanusGraph/janusgraph

@Override
@After
public void tearDown() throws Exception {
  executor.shutdown();
  if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
    log.error("Abnormal executor shutdown");
    Thread.dumpStack();
  } else {
    log.debug("Test executor completed normal shutdown");
  }
  super.tearDown();
}

代码示例来源:origin: objectbox/objectbox-java

/** dump thread stacks if pool does not terminate promptly. */
private void checkThreadTermination() {
  try {
    if (!threadPool.awaitTermination(1, TimeUnit.SECONDS)) {
      int activeCount = Thread.activeCount();
      System.err.println("Thread pool not terminated in time; printing stack traces...");
      Thread[] threads = new Thread[activeCount + 2];
      int count = Thread.enumerate(threads);
      for (int i = 0; i < count; i++) {
        System.err.println("Thread: " + threads[i].getName());
        Thread.dumpStack();
      }
    }
  } catch (InterruptedException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: apache/geode

public PortfolioPdx(int i) {
 aDay = (Day) (dayList.get((i % dayList.size())));
 if (DEBUG)
  Thread.dumpStack();
 this.numInstance++;
 ID = i;

代码示例来源:origin: plantuml/plantuml

public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
  final UText shape = (UText) ushape;
  Thread.dumpStack();
  final FontConfiguration fontConfiguration = shape.getFontConfiguration();
  final UFont font = fontConfiguration.getFont();
  String text = shape.getText();
  if (text.startsWith(" ")) {
    final double space = stringBounder.calculateDimension(font, " ").getWidth();
    while (text.startsWith(" ")) {
      x += space;
      text = text.substring(1);
    }
  }
  text = StringUtils.trin(text);
  final Dimension2D dim = stringBounder.calculateDimension(font, text);
  visio.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), dim.getWidth(), dim.getHeight(),
      fontConfiguration.getAttributes());
}

代码示例来源:origin: stackoverflow.com

@Aspect
public class EDTCheck {

  @Pointcut("call (* javax.swing..*+.*(..)) || " +
       "call (javax.swing..*+.new(..))")
  public void swingMethods() {}

  @Pointcut("call (* com.mystuff.swing..*+.*(..)) || " +
       "call (com.mystuff.swing..*+.new(..))")
  public void mySwingMethods() {}

  @Pointcut("call (* javax.swing..*+.add*Listener(..)) || " +
       "call (* javax.swing..*+.remove*Listener(..)) || " +
       "call (void javax.swing.JComponent+.setText(java.lang.String))")
  public void safeMethods() {}

  @Before("(swingMethods() || mySwingMethods()) && !safeMethods()")
  public void checkCallingThread(JoinPoint.StaticPart thisJoinPointStatic) {
    if(!SwingUtilities.isDispatchThread()) {
      System.out.println(
          "Swing single thread rule violation: " 
          + thisJoinPointStatic);
      Thread.dumpStack();
      // or you might throw an unchecked exception
    }
  }

}

代码示例来源:origin: structr/structr

@Override
public Iterator<T> iterator() {
  if (isConsumed()) {
    logger.error("PagingIterable already consumed, please use Iterables.toList() to be able to iterate a streaming result more than once.");
    Thread.dumpStack();
  }
  return source;
}

代码示例来源:origin: dadoonet/fscrawler

public void close() throws InterruptedException, IOException {
  logger.debug("Closing FS crawler [{}]", settings.getName());
  if (fsParser != null) {
    fsParser.close();
    synchronized(fsParser.getSemaphore()) {
      fsParser.getSemaphore().notifyAll();
    }
  }
  if (this.fsCrawlerThread != null) {
    while (fsCrawlerThread.isAlive()) {
      // We check that the crawler has been closed effectively
      logger.debug("FS crawler thread is still running");
      if (logger.isDebugEnabled()) {
        Thread.dumpStack();
      }
      Thread.sleep(500);
    }
    logger.debug("FS crawler thread is now stopped");
  }
  esClient.close();
  logger.debug("ES Client Manager stopped");
  logger.info("FS crawler [{}] stopped", settings.getName());
}

代码示例来源:origin: com.atlassian.jira/jira-api

public GenericValue getGenericValue()
{
  if (debug)
    Thread.dumpStack();
  return genericValue;
}

代码示例来源:origin: com.atlassian.jira/jira-api

public Timestamp getTimestamp(String name)
{
  if (debug)
    Thread.dumpStack();
  return genericValue.getTimestamp(name);
}

代码示例来源:origin: com.atlassian.jira/jira-api

public Long getLong(String name)
{
  if (debug)
    Thread.dumpStack();
  return genericValue.getLong(name);
}

代码示例来源:origin: com.atlassian.jira/jira-api

public String getString(String name)
{
  if (debug)
    Thread.dumpStack();
  return genericValue.getString(name);
}

相关文章