. , . , , .
- :
public class Debugger implements Serializable {
private static final long serialVersionUID = 1L;
private Thread parent;
private String packageName;
private File outputFile;
private boolean alive;
public Debugger(Thread parent, String packageName, File outputFile) {
this.parent = parent;
this.packageName = packageName;
this.outputFile = outputFile;
alive = true;
}
public void run() throws FileNotFoundException {
PrintStream ps = new PrintStream(outputFile);
alive = true;
String lastClassName = "";
while (parent.isAlive() && alive) {
for (StackTraceElement ste : parent.getStackTrace()) {
if (ste.getClassName().startsWith(packageName)) {
if (!ste.getClassName().equals(lastClassName)) {
ps.println(ste.toString());
lastClassName = ste.getClassName();
}
break;
}
}
}
ps.close();
}
public void kill() {
alive = false;
}
}
, , / . kill() , . , , / , , , , .
( ()), , .
, , , . , .