57 } catch(InterruptedException e) {
58 throw new RuntimeException("Thread got interrupted...");
59 }
60 }
61
62 switchPlayer.stop();
63 try {
64 switchThread.join();
65 } catch(InterruptedException e) {
66 throw new RuntimeException("Thread got interrupted while waiting for the switch player...");
67 }
68
69 // We don't check here for correctness of data. If we made it here, the test succeeded:
70 // Threads can allocate like crazy
71 // Other threads can turn on/off the system
72 }
73 }
74
75 class Allocator implements Runnable {
76 private int depth;
77 private int g_tmp[];
78
79 public Allocator(int depth) {
80 this.depth = depth;
81 }
82
83 private int helper() {
84 int sum = 0;
85 // Let us assume that the array is 24 bytes of memory.
86 for (int i = 0; i < 127000 / 6; i++) {
87 int tmp[] = new int[1];
88 // Force it to be kept.
89 g_tmp = tmp;
90 sum += g_tmp[0];
91 }
92 return sum;
93 }
94
95 private int recursiveWrapper(int depth) {
96 if (depth > 0) {
97 return recursiveWrapper(depth - 1);
98 }
99 return helper();
100 }
101
102 public void run() {
103 int sum = 0;
104 for (int j = 0; j < 500; j++) {
105 sum += recursiveWrapper(depth);
106 }
107 }
108 }
109
110 class Switch implements Runnable {
|
57 } catch(InterruptedException e) {
58 throw new RuntimeException("Thread got interrupted...");
59 }
60 }
61
62 switchPlayer.stop();
63 try {
64 switchThread.join();
65 } catch(InterruptedException e) {
66 throw new RuntimeException("Thread got interrupted while waiting for the switch player...");
67 }
68
69 // We don't check here for correctness of data. If we made it here, the test succeeded:
70 // Threads can allocate like crazy
71 // Other threads can turn on/off the system
72 }
73 }
74
75 class Allocator implements Runnable {
76 private int depth;
77 private volatile int tmp[];
78
79 public Allocator(int depth) {
80 this.depth = depth;
81 }
82
83 private int helper() {
84 int sum = 0;
85 // Let us assume that the array is 24 bytes of memory.
86 for (int i = 0; i < 127000 / 6; i++) {
87 int newTmp[] = new int[1];
88 // Force it to be kept.
89 tmp = newTmp;
90 sum += tmp[0];
91 }
92 return sum;
93 }
94
95 private int recursiveWrapper(int depth) {
96 if (depth > 0) {
97 return recursiveWrapper(depth - 1);
98 }
99 return helper();
100 }
101
102 public void run() {
103 int sum = 0;
104 for (int j = 0; j < 500; j++) {
105 sum += recursiveWrapper(depth);
106 }
107 }
108 }
109
110 class Switch implements Runnable {
|