Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //package debugger;
  2. import com.sun.jdi.*;
  3. import com.sun.jdi.event.*;
  4. import com.sun.jdi.request.*;
  5. import java.io.*;
  6. import java.util.*;
  7. import org.aspectj.tools.debugger.*;
  8. /**
  9. * ThreadTester.java
  10. *
  11. *
  12. * Created: Wed Sep 27 13:56:44 2000
  13. *
  14. * @author <a href="mailto:palm@parc.xerox.com"Jeffrey Palm</a>
  15. */
  16. public class ThreadTester extends Tester {
  17. public static void main(String[] args) {
  18. new Main(new ThreadTester(false), args);
  19. }
  20. public ThreadTester(boolean d) {
  21. super(d);
  22. }
  23. public String getClassName() {
  24. return "AJDBThreads";
  25. }
  26. public boolean test() {
  27. db();
  28. try {
  29. stopon(43);
  30. stop1();
  31. startTest();
  32. quit();
  33. return true;
  34. } catch (DebuggerException de) {
  35. de.printStackTrace();
  36. }
  37. return false;
  38. }
  39. protected void stop1() {
  40. d.addStopListener(new StopAdapter() {
  41. int times = 0;
  42. int stopTimes = 0;
  43. int max = 5;
  44. int stopMax = 3;
  45. String thread = "";
  46. Pair[] pairs = new Pair[max];
  47. class Pair {
  48. String thread;
  49. int time;
  50. Pair(String thread, int time) {
  51. this.thread = thread;
  52. this.time = time;
  53. }
  54. }
  55. public void breakpointEvent(BreakpointEvent e) {
  56. try {
  57. String threadName = d.getDefaultThread().name();
  58. msg("stop times=" + times + " thread=" + threadName);
  59. if ((++times) < max) {
  60. thread = threadName;
  61. Pair pair = new Pair(thread, times);
  62. pairs[times] = pair;
  63. step();
  64. } else {
  65. quit();
  66. }
  67. } catch (DebuggerException de) {
  68. de(de);
  69. }
  70. }
  71. public void stepEvent(StepEvent se) {
  72. try {
  73. ThreadReference threadRef = d.getDefaultThread();
  74. check(pairs[times].thread.equals(thread), "Should step in *one* thread");
  75. msg("\ttimes=" + times + ":" + stopTimes + " thread=" + threadRef.name());
  76. if ((++stopTimes) < stopMax) {
  77. step();
  78. } else {
  79. stopTimes = 0;
  80. cont();
  81. }
  82. } catch (DebuggerException de) {
  83. de(de);
  84. }
  85. }
  86. });
  87. }
  88. protected long getMaxStallTime() {
  89. return (long) 3 * super.getMaxStallTime();
  90. }
  91. }