Skip to content

Instantly share code, notes, and snippets.

@zhongl
Created May 22, 2013 05:08
Show Gist options
  • Save zhongl/5625366 to your computer and use it in GitHub Desktop.
Save zhongl/5625366 to your computer and use it in GitHub Desktop.
`StackOverflow` trap in using BTrace.
import java.lang.Exception;
/*
TODO: Btrace `jps | grep StackOverflow | grep -oE '[0-9]+'` Script.java
import com.sun.btrace.annotations.*;
import com.sun.btrace.AnyType;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class Script {
@OnMethod(clazz = "java.lang.Thread" , method = "getId")
public static void trace(@ProbeMethodName String pmn, AnyType[] args) {
print(pmn);
printArray(args);
}
}
*/
public class StackOverflow {
public static void main(String[] args) {
while (true){
try {
Thread.sleep(2000L);
System.out.println("tick thread id: " + Thread.currentThread().getId());
} catch (Exception e) {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment