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

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

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

Thread.countStackFrames介绍

[英]Counts the number of stack frames in this thread. The thread must be suspended.
[中]统计此线程中的堆栈帧数。线程必须挂起。

代码示例

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

public static int levelsDeep() {
  return Thread.currentThread().countStackFrames();       
}

代码示例来源:origin: javapathfinder/jpf-core

@Test 
@SuppressWarnings("deprecation")
public void testInfiniteRecursion (){
 if (verifyUnhandledException("java.lang.StackOverflowError", 
   "+listener=.listener.StackDepthChecker", "+sdc.max_stack_depth=42")){
  Thread t = Thread.currentThread();
  n = t.countStackFrames(); // it's deprecated, but we just want to make the printout more readable
  foo();
 }
}

相关文章

微信公众号

最新文章

更多