|
35 | 35 | import org.graalvm.visualvm.lib.jfluid.heap.JavaClass;
|
36 | 36 | import org.netbeans.api.progress.ProgressHandle;
|
37 | 37 | import org.openide.util.NbBundle;
|
| 38 | +import org.openide.util.RequestProcessor; |
38 | 39 |
|
39 | 40 | /**
|
40 | 41 | *
|
@@ -82,10 +83,10 @@ public static void initializeRetainedSizes(Heap heap) throws InterruptedExceptio
|
82 | 83 | // --- References ----------------------------------------------------------
|
83 | 84 |
|
84 | 85 | private static boolean referencesInitialized;
|
85 |
| - private static volatile Thread referencesComputer; |
| 86 | + private static volatile RequestProcessor.Task referencesComputer; |
86 | 87 |
|
87 | 88 | private void initializeReferencesImpl(Heap heap) throws InterruptedException {
|
88 |
| - Thread _referencesComputer; |
| 89 | + RequestProcessor.Task _referencesComputer; |
89 | 90 |
|
90 | 91 | synchronized (this) {
|
91 | 92 | if (referencesInitialized) return;
|
@@ -114,29 +115,28 @@ public void run() {
|
114 | 115 | }
|
115 | 116 | }
|
116 | 117 | };
|
117 |
| - referencesComputer = new Thread(workerR, "References Computer"); // NO18N |
118 |
| - _referencesComputer = referencesComputer; // NOTE: must be assigned before starting the thread which eventually nulls the referencesComputer! |
119 |
| - referencesComputer.start(); |
| 118 | + referencesComputer = new RequestProcessor("References Computer").post(workerR); // NO18N |
| 119 | + _referencesComputer = referencesComputer; |
120 | 120 | } else {
|
121 | 121 | _referencesComputer = referencesComputer;
|
122 | 122 | }
|
123 | 123 | }
|
124 | 124 |
|
125 | 125 | assert !SwingUtilities.isEventDispatchThread();
|
126 | 126 |
|
127 |
| - _referencesComputer.join(); |
| 127 | + _referencesComputer.waitFinished(0); |
128 | 128 | }
|
129 | 129 |
|
130 | 130 |
|
131 | 131 | // --- GC Roots ------------------------------------------------------------
|
132 | 132 |
|
133 | 133 | private static boolean gcrootsInitialized;
|
134 |
| - private static volatile Thread gcrootsComputer; |
| 134 | + private static volatile RequestProcessor.Task gcrootsComputer; |
135 | 135 |
|
136 | 136 | private void initializeGCRootsImpl(Heap heap) throws InterruptedException {
|
137 | 137 | initializeReferencesImpl(heap);
|
138 | 138 |
|
139 |
| - Thread _gcrootsComputer; |
| 139 | + RequestProcessor.Task _gcrootsComputer; |
140 | 140 |
|
141 | 141 | synchronized (this) {
|
142 | 142 | if (gcrootsInitialized) return;
|
@@ -165,29 +165,27 @@ public void run() {
|
165 | 165 | }
|
166 | 166 | }
|
167 | 167 | };
|
168 |
| - gcrootsComputer = new Thread(workerR, "GC Roots Computer"); // NO18N |
169 |
| - _gcrootsComputer = gcrootsComputer; // NOTE: must be assigned before starting the thread which eventually nulls the gcrootsComputer! |
170 |
| - gcrootsComputer.start(); |
| 168 | + gcrootsComputer = new RequestProcessor("GC Roots Computer").post(workerR); // NO18N |
| 169 | + _gcrootsComputer = gcrootsComputer; |
171 | 170 | } else {
|
172 | 171 | _gcrootsComputer = gcrootsComputer;
|
173 | 172 | }
|
174 | 173 | }
|
175 | 174 |
|
176 | 175 | assert !SwingUtilities.isEventDispatchThread();
|
177 | 176 |
|
178 |
| - _gcrootsComputer.join(); |
| 177 | + _gcrootsComputer.waitFinished(0); |
179 | 178 | }
|
180 | 179 |
|
181 |
| - |
182 | 180 | // --- GC Roots ------------------------------------------------------------
|
183 | 181 |
|
184 | 182 | private static boolean retainedInitialized;
|
185 |
| - private static volatile Thread retainedComputer; |
| 183 | + private static volatile RequestProcessor.Task retainedComputer; |
186 | 184 |
|
187 | 185 | private void initializeRetainedSizesImpl(Heap heap) throws InterruptedException {
|
188 | 186 | initializeGCRootsImpl(heap);
|
189 | 187 |
|
190 |
| - Thread _retainedComputer; |
| 188 | + RequestProcessor.Task _retainedComputer; |
191 | 189 |
|
192 | 190 | synchronized (this) {
|
193 | 191 | if (retainedInitialized) return;
|
@@ -216,17 +214,16 @@ public void run() {
|
216 | 214 | }
|
217 | 215 | }
|
218 | 216 | };
|
219 |
| - retainedComputer = new Thread(workerR, "Retained Sizes Computer"); // NO18N |
220 |
| - _retainedComputer = retainedComputer; // NOTE: must be assigned before starting the thread which eventually nulls the retainedComputer! |
221 |
| - retainedComputer.start(); |
| 217 | + retainedComputer = new RequestProcessor("Retained Sizes Computer").post(workerR); // NO18N |
| 218 | + _retainedComputer = retainedComputer; |
222 | 219 | } else {
|
223 | 220 | _retainedComputer = retainedComputer;
|
224 | 221 | }
|
225 | 222 | }
|
226 | 223 |
|
227 | 224 | assert !SwingUtilities.isEventDispatchThread();
|
228 | 225 |
|
229 |
| - _retainedComputer.join(); |
| 226 | + _retainedComputer.waitFinished(0); |
230 | 227 | }
|
231 | 228 |
|
232 | 229 | }
|
0 commit comments